Opened 12 years ago
Last modified 5 years ago
#18517 closed Bug
URLField does not support url with underscore — at Version 2
Reported by: | guoqiao | Owned by: | nobody |
---|---|---|---|
Component: | Core (URLs) | Version: | 1.6 |
Severity: | Normal | Keywords: | URLFiled |
Cc: | guoqiao | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
if your url has a '_' in it, like this:
the URLField will complain that it is not a valid url. the problem lies in the '_' symbol. I find in the source code as Following:
class URLValidator(RegexValidator): regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain... 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)
the related part is this line:
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'
It's clear that '_' is not included in the pattern.
I think this is not reaonable for there's a lot of url has a '_' in it.
Change History (2)
comment:1 by , 12 years ago
Cc: | added |
---|---|
Component: | Uncategorized → Core (URLs) |
Easy pickings: | set |
Keywords: | URLFiled added |
Type: | Uncategorized → Bug |
comment:2 by , 12 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.
Reformatted, please use preview before posting the ticket.