As suggested by Eric, we'll use a regex from https://mathiasbynens.be/demo/url-regex,

specifically the one by @imme_emosol
pull/1/head
Raymond Yee 2014-10-13 16:21:30 -07:00
parent 842c0e07e1
commit 08e1806db2
1 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@
external library imports
"""
import logging
import re
import zipfile
from datetime import timedelta, datetime, date
@ -130,7 +131,9 @@ class EditionForm(forms.ModelForm):
)
http = forms.RegexField(
label=_("HTTP URL"),
regex=r'^(https?\://[a-zA-Z0-9\-_\%\~\$\?\(\)\&\!\;\:\.\,\+\=]*|delete)$',
# https://mathiasbynens.be/demo/url-regex
regex=re.compile(r"(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$",
flags=re.IGNORECASE|re.S ),
required = False,
help_text = _("no spaces of funny stuff."),
error_messages = {