Author: russellm Date: 2009-04-16 10:00:20 -0500 (Thu, 16 Apr 2009) New Revision: 10577
Modified: django/branches/releases/1.0.X/django/forms/fields.py django/branches/releases/1.0.X/tests/regressiontests/forms/fields.py Log: [1.0.X] Fixed #9948 -- Corrected URLField validation to match RFC1035 (URL analog of #9890). Thanks to kratorius for the report and fix. Merge of r10574 from trunk. Modified: django/branches/releases/1.0.X/django/forms/fields.py =================================================================== --- django/branches/releases/1.0.X/django/forms/fields.py 2009-04-16 14:59:37 UTC (rev 10576) +++ django/branches/releases/1.0.X/django/forms/fields.py 2009-04-16 15:00:20 UTC (rev 10577) @@ -532,7 +532,7 @@ url_re = re.compile( r'^https?://' # http:// or https:// - r'(?:(?:[A-Z0-9-]+\.)+[A-Z]{2,6}|' #domain... + r'(?:(?:[A-Z0-9]+(?:-*[A-Z0-9]+)*\.)+[A-Z]{2,6}|' #domain... r'localhost|' #localhost... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip r'(?::\d+)?' # optional port Modified: django/branches/releases/1.0.X/tests/regressiontests/forms/fields.py =================================================================== --- django/branches/releases/1.0.X/tests/regressiontests/forms/fields.py 2009-04-16 14:59:37 UTC (rev 10576) +++ django/branches/releases/1.0.X/tests/regressiontests/forms/fields.py 2009-04-16 15:00:20 UTC (rev 10577) @@ -900,6 +900,10 @@ u'http://www.example.com/' >>> f.clean('http://www.example.com:8000/test') u'http://www.example.com:8000/test' +>>> f.clean('valid-with-hyphens.com') +u'http://valid-with-hyphens.com/' +>>> f.clean('subdomain.domain.com') +u'http://subdomain.domain.com/' >>> f.clean('http://200.8.9.10') u'http://200.8.9.10/' >>> f.clean('http://200.8.9.10:8000/test') @@ -924,6 +928,24 @@ Traceback (most recent call last): ... ValidationError: [u'Enter a valid URL.'] +>>> f.clean('http://invalid-.com') +Traceback (most recent call last): +... +ValidationError: [u'Enter a valid URL.'] +>>> f.clean('http://-invalid.com') +Traceback (most recent call last): +... +ValidationError: [u'Enter a valid URL.'] +>>> f.clean('http://inv-.alid-.com') +Traceback (most recent call last): +... +ValidationError: [u'Enter a valid URL.'] +>>> f.clean('http://inv-.-alid.com') +Traceback (most recent call last): +... +ValidationError: [u'Enter a valid URL.'] +>>> f.clean('http://valid-----hyphens.com') +u'http://valid-----hyphens.com/' >>> f = URLField(required=False) >>> f.clean('') --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---