diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-11-12 20:25:47 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-11-12 20:25:47 +0000 |
| commit | 0a74c68eeebb827736f2370dc67d0d72619025f2 (patch) | |
| tree | faaa420af90cf787acb3c00c3ab6fea837159415 | |
| parent | 1bf6dd7e0e0738b3d4c6c818124f8ecfa3a99936 (diff) | |
Fixed #778 -- Improved isExistingURL validator not to raise ValidationError for URLs that exist but require authorization. Thanks for the report, lakin wrecker.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1202 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/validators.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index bdcce990f8..b68fc0ade8 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -199,7 +199,11 @@ def isExistingURL(field_data, all_data): u = urllib2.urlopen(field_data) except ValueError: raise ValidationError, _("Invalid URL: %s") % field_data - except: # urllib2.HTTPError, urllib2.URLError, httplib.InvalidURL, etc. + except urllib2.HTTPError, e: + # 401s are valid; they just mean authorization is required. + if e.code not in ('401',): + raise ValidationError, _("The URL %s is a broken link.") % field_data + except: # urllib2.URLError, httplib.InvalidURL, etc. raise ValidationError, _("The URL %s is a broken link.") % field_data def isValidUSState(field_data, all_data): |
