Skip to content
Snippets Groups Projects
Commit 817d4d2e authored by Jonas Leder's avatar Jonas Leder
Browse files

qr codes wil now have http or https not only http and recaptcha skip fix

parent 4add2616
No related branches found
No related tags found
No related merge requests found
Pipeline #57 passed
......@@ -121,6 +121,7 @@ def makeQR(text): #This function is used to create a QR code and encode it base6
def grecaptcha_verify(request): #This function is used to verify the google recaptcha code, that is send to the server after submitting a new link
if(skipCaptcha): return True #If recaptcha is disabled alwas return at this point true, which means response is verified
captcha_rs = request.form.get('g-recaptcha-response')
url = "https://www.google.com/recaptcha/api/siteverify" #The baseurl
headers = {'User-Agent': 'DebuguearApi-Browser',} #Useragent doesn't matters, but is set here
......@@ -151,7 +152,7 @@ def home_post():
except:
userID = "null"
loginbar = '<a href="/user/login" style="color:white">login</a>'
if not grecaptcha_verify(request) and not skipCaptcha:
if not grecaptcha_verify(request):
return render_template('home.html', builddate=builddate, version=version, domain=domain_prepared, snackbar="There was an error validating, that you are a human, please try again.", long_url_prefilled=request.form.get('url'), short_url_prefilled=request.form.get('short').lower(), domain_prefilled=domain_to_index[request.form.get('domain')], recaptchaPublicKey=recaptchaPublicKey, showDomainSelect=showDomainSelect, loginbar=loginbar) #return the user the prefilled form with an error message, because no url to short was provided
if (request.form.get('url').replace(" ", "") == ""):
......@@ -177,7 +178,7 @@ def home_post():
'INSERT INTO WEB_URL (LONG_URL, SHORT_URL, USERNAME) VALUES (?, ?, ?)',
[url, shorturl, userID]
)
return render_template('home.html', short_url=shorturl, recaptchaPublicKey=recaptchaPublicKey, builddate=builddate, version=version, domain=domain_prepared, qrcode=makeQR("http://" + shorturl), loginbar=loginbar) #return the shorten link to the user
return render_template('home.html', short_url=shorturl, recaptchaPublicKey=recaptchaPublicKey, builddate=builddate, version=version, domain=domain_prepared, qrcode=makeQR(url_scheme + "://" + shorturl), loginbar=loginbar) #return the shorten link to the user
else:
return render_template('home.html', builddate=builddate, version=version, recaptchaPublicKey=recaptchaPublicKey, domain=domain_prepared, snackbar="URL already used, please try another one", long_url_prefilled=request.form.get('url'), short_url_prefilled=request.form.get('short').lower(), domain_prefilled=domain_to_index[request.form.get('domain')], showDomainSelect=showDomainSelect, loginbar=loginbar) #return the user the prefilled form with an error message, because the url was already used
......@@ -278,7 +279,7 @@ def delete():
@app.route('/user/makeqr')
def makeQrCode():
link = request.args.get('link')
return "data:image/jpeg;base64," + makeQR("http://" + link)
return "data:image/jpeg;base64," + makeQR(url_scheme + "://" + link)
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment