Some basic URL validation

This commit is contained in:
2018-10-17 14:15:00 +02:00
parent 444b9ecf9d
commit 5d6db5aea5
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -4,8 +4,8 @@ from PIL import Image, ImageFont, ImageDraw
import qrcode
from io import BytesIO
import json, random, re, string
app = Flask(__name__)
app = Flask(__name__)
systemURL = 'http://192.168.0.11:5000/'
randomchars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789' #note the lack of zero
@@ -70,6 +70,10 @@ def edit():
if url is None:
return render_template('editlink.html', code=code)
#Saving the link:
if url.lower().startswith('https://') is False and url.lower().startswith('http://') is False:
return render_template('message.html', message="Only http:// and https:// links alowed. Plz fix your link!")
if len(url)>1000:
return render_template('message.html', message="This link is too long! It probably contains tracking data or other crap. Please find a shorter link.")
links[code]['url']=url
saveFile()
return render_template('success.html')