From 817d4d2ea8d9b2cd5a0543a62dc72ef9daf73821 Mon Sep 17 00:00:00 2001 From: Jonas Leder <jonas@jonasled.de> Date: Sun, 10 Nov 2019 15:04:47 +0100 Subject: [PATCH] qr codes wil now have http or https not only http and recaptcha skip fix --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 3e590f2..bca506c 100644 --- a/main.py +++ b/main.py @@ -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__': -- GitLab