Opened 2 years ago

Closed 2 years ago

#17684 closed Bug (wontfix)

URLValidator: Validation fails when URL requires User-Agent header

Reported by: pennersr Owned by: nobody
Component: Core (URLs) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The following example shows a link that returns a 403 in case no user agent is passed. When passed, a proper 200 is returned. However, this does not seem to work with the URLValidator. The ValidationError is unexpected here...

>>> import django
>>> django.VERSION
(1, 3, 1, 'final', 0)
>>> import requests
>>> from django.core.validators import URLValidator
>>> ua = 'foobar'
>>> requests.get('')
<Response [403]>
>>> requests.get('', headers={ 'User-Agent': ua})
<Response [200]>
>>> URLValidator(verify_exists=True, validator_user_agent=ua)('')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "...HIDDEN.../django/django/core/", line 121, in __call__
    raise broken_error
ValidationError: [u'This URL appears to be a broken link.']

(Python 2.6.5)

Attachments (0)

Change History (1)

comment:1 Changed 2 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Thanks for reporting this bug. However, the URL verification feature was removed in Django 1.4, thus "resolving" the issue. See r16760

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.