|
From: <sub...@co...> - 2008-05-13 22:40:02
|
Author: ianb
Date: 2008-05-13 16:40:04 -0600 (Tue, 13 May 2008)
New Revision: 3418
Modified:
FormEncode/trunk/docs/news.txt
FormEncode/trunk/formencode/validators.py
Log:
Adjustments to the URL validator (SF bug 1940971) from Jonathan Vanesco
Modified: FormEncode/trunk/docs/news.txt
===================================================================
--- FormEncode/trunk/docs/news.txt 2008-05-13 21:47:44 UTC (rev 3417)
+++ FormEncode/trunk/docs/news.txt 2008-05-13 22:40:04 UTC (rev 3418)
@@ -21,6 +21,8 @@
* The validators ``Int`` and ``Number`` both take min/max arguments
(from Shannon Behrens).
+* Some adjustments to the URL validator.
+
1.0.1
-----
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2008-05-13 21:47:44 UTC (rev 3417)
+++ FormEncode/trunk/formencode/validators.py 2008-05-13 22:40:04 UTC (rev 3418)
@@ -1379,10 +1379,26 @@
check_exists = False
add_http = True
- url_re = re.compile(r'^(http|https)://'
- r'(?:[a-z0-9\-]+|[a-z0-9][a-z0-9\-\.\_]*\.[a-z]+)'
- r'(?::[0-9]+)?'
- r'(?:/.*)?$', re.I)
+ url_re = re.compile(r'''
+ ^(http|https)://
+ (?:[%:\w]*@)? # authenticator
+ (?:[a-z0-9][a-z0-9\-]{1,62}\.)* # (sub)domain - alpha followed by 62max chars (63 total)
+ [a-z]+ # TLD
+ (?:[0-9]+)? # port
+
+ # files/delims/etc
+ (?:/[
+ # rfc3986 valid chars
+ # unreserved
+ a-z0-9\-\._~
+ # delims - general
+ :/\?#\[\]@
+ # delims - sub
+ !\$&\'\(\)\*\+,;=
+ ]*)?
+ $
+ ''', re.I | re.VERBOSE)
+
scheme_re = re.compile(r'^[a-zA-Z]+:')
messages = {
|