Opened 12 years ago

Closed 12 years ago

#19825 closed Bug (invalid)

URLValidator

Reported by: agestart@… 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)

URLValidator.patch (1.2 KB ) - added by agestart@… 12 years ago.
patch

Download all attachments as: .zip

Change History (3)

by agestart@…, 12 years ago

Attachment: URLValidator.patch added

patch

comment:1 by akiala, 12 years ago

comment:2 by Carl Meyer, 12 years ago

Resolution: invalid
Status: newclosed

A valid URL cannot have a space in it, it must be encoded as %20.

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