Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #778 -- Improved isExistingURL validator not to raise Validatio…

…nError 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
  • Loading branch information...
commit 0a74c68eeebb827736f2370dc67d0d72619025f2 1 parent 1bf6dd7
Adrian Holovaty authored November 12, 2005

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  django/core/validators.py
6  django/core/validators.py
@@ -199,7 +199,11 @@ def isExistingURL(field_data, all_data):
199 199
         u = urllib2.urlopen(field_data)
200 200
     except ValueError:
201 201
         raise ValidationError, _("Invalid URL: %s") % field_data
202  
-    except: # urllib2.HTTPError, urllib2.URLError, httplib.InvalidURL, etc.
  202
+    except urllib2.HTTPError, e:
  203
+        # 401s are valid; they just mean authorization is required.
  204
+        if e.code not in ('401',):
  205
+            raise ValidationError, _("The URL %s is a broken link.") % field_data
  206
+    except: # urllib2.URLError, httplib.InvalidURL, etc.
203 207
         raise ValidationError, _("The URL %s is a broken link.") % field_data
204 208
 
205 209
 def isValidUSState(field_data, all_data):

0 notes on commit 0a74c68

Please sign in to comment.
Something went wrong with that request. Please try again.