Opened 12 years ago

Last modified 4 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 Claude Paroz)

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 guoqiao, 12 years ago

Cc: guoqiao added
Component: UncategorizedCore (URLs)
Easy pickings: set
Keywords: URLFiled added
Type: UncategorizedBug

comment:2 by Claude Paroz, 12 years ago

Description: modified (diff)

Reformatted, please use preview before posting the ticket.

Note: See TracTickets for help on using tickets.
Back to Top