Opened 16 years ago
Closed 16 years ago
#9918 closed (worksforme)
URL field validation false negative
Reported by: | Steven Skoczen | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.0 |
Severity: | Keywords: | URLField validation | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello,
Just reporting that the validation for URLFields fails incorrectly with URLs similar to the below.
Original case:
http://www.ens-newswire.com/ens/jun2007/2007-06-05-09.asp#anchor2
is incorrectly rejected.
Change History (5)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:3 by , 16 years ago
I definitely have a plain-vanilla URLField that fails on that url and the cases noted above in real usage (oggy's code works fine for me). Will dig into this and see what's happening.
comment:4 by , 16 years ago
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
Nope, this is definitely an issue. I haven't been able to track down what's causing it, but I get it in a brand-new app, for an otherwise well-behaved URLField.
To reproduce, try entering one of the above URLs into any admin interface URLField, or use an app like the below:
urls.py:
from django.conf.urls.defaults import * from test_app.models import * urlpatterns = patterns('django.views.generic.create_update', (r'^', 'create_object',{'model':TestModel}), )
settings.py:
ROOT_URLCONF = 'urls' import os PROJECT_PATH = os.path.abspath(os.path.dirname(__file__)) TEMPLATE_DIRS = ( os.path.join(PROJECT_PATH, 'templates') ) INSTALLED_APPS = ( 'test_app', )
test_app/models.py:
from django.db import models # Create your models here. class TestModel(models.Model): test_url = models.URLField()
templates/test_app/testmodel_form.html
<html><head></head> <body> <form action="." method="POST"> {{form}} <input type="submit"/> </form> </body>
On runserver, and load of 127.0.0.1:8000, enter one of the URLs in the original ticket, and receive "This URL appears to be a broken link."
comment:5 by , 16 years ago
Resolution: | → worksforme |
---|---|
Status: | reopened → closed |
You get that error because verify_exists
is True
on models.URLField (see http://docs.djangoproject.com/en/dev/ref/models/fields/#urlfield). In other words it will make sure that the above URLs won't return a 404. If you don't need this functionality just set verify_exists
to False
(and it gives a that error on the second URL because that particular server will return a 400 error code for that).
Cannot reproduce with v9690. The URLField regex seems OK to me.