Changes between Initial Version and Version 2 of Ticket #18517


Ignore:
Timestamp:
Jun 26, 2012, 4:29:21 AM (12 years ago)
Author:
Claude Paroz
Comment:

Reformatted, please use preview before posting the ticket.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #18517

    • Property Cc guoqiao added
    • Property Component UncategorizedCore (URLs)
    • Property Easy pickings set
    • Property Keywords URLFiled added
    • Property Type UncategorizedBug
  • Ticket #18517 – Description

    initial v2  
    11if your url has a '_' in it, like this:
    2 http://django_compressor.readthedocs.org/
     2 * http://django_compressor.readthedocs.org/
    33the URLField will complain that it is not a valid url. the problem lies in the '_' symbol. I find in the source code as Following:
    4 class URLValidator(RegexValidator):                                                                 
    5     regex = re.compile(                                                                             
    6         r'^(?:http|ftp)s?://' # http:// or https://                                                 
    7         r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...                                                               
    8         r'localhost|' #localhost...                                                                 
    9         r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip                                           
    10         r'(?::\d+)?' # optional port                                                               
    11         r'(?:/?|[/?]\S+)$', re.IGNORECASE) 
     4{{{
     5class URLValidator(RegexValidator):
     6    regex = re.compile(
     7        r'^(?:http|ftp)s?://' # http:// or https://
     8        r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
     9        r'localhost|' #localhost...
     10        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
     11        r'(?::\d+)?' # optional port
     12        r'(?:/?|[/?]\S+)$', re.IGNORECASE)
     13}}}
     14
    1215the related part is this line:
     16{{{
    1317r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'
     18}}}
     19
    1420It's clear that '_' is not included in the pattern.
    1521I think this is not reaonable for there's a lot of url has a '_' in it.
Back to Top