Opened 13 years ago
Closed 13 years ago
#19825 closed Bug (invalid)
URLValidator
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Forms | Version: | 1.4 |
| Severity: | Normal | Keywords: | urlvalidator url field validator |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
if url have space i get error "raise ValidationError(_(u'Enter a valid URL.'), code='invalid')" if I quote link I get "broken_error".
I created the patch:
*** core/validators.py 2012-11-21 12:55:55.675173918 +0400
--- core/validators.py 2012-11-21 15:31:57.895171400 +0400
***************
*** 50,56 ****
r'localhost|' #localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
! r'(?:/?|[/?]\S+)$', re.IGNORECASE)
def __init__(self, verify_exists=False,
validator_user_agent=URL_VALIDATOR_USER_AGENT):
--- 50,56 ----
r'localhost|' #localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
! r'(?:/?|[/?].+)$', re.IGNORECASE)
def __init__(self, verify_exists=False,
validator_user_agent=URL_VALIDATOR_USER_AGENT):
***************
*** 94,99 ****
--- 94,100 ----
}
url = url.encode('utf-8')
# Quote characters from the unreserved set, refs #16812
+ url = '%' in url and urllib.unquote(url) or url
url = urllib.quote(url, "!*'();:@&=+$,/?#[]")
broken_error = ValidationError(
_(u'This URL appears to be a broken link.'), code='invalid_link')
Attachments (1)
Change History (3)
by , 13 years ago
| Attachment: | URLValidator.patch added |
|---|
comment:1 by , 13 years ago
comment:2 by , 13 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
A valid URL cannot have a space in it, it must be encoded as %20.
Note:
See TracTickets
for help on using tickets.
patch