turns out there is a problem, the field looks for "://" anywhere on the
value but according to the RFC the colon is allowed on paths, so an url like
'www.example.com/://' should validate and it fails:

Python 2.6.4 (r264:75706, Jan 25 2010, 08:55:26)
[GCC 4.4.2 20091208 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import django
>>> django.VERSION
(1, 2, 1, 'final', 0)
>>> from django import forms
>>> class MyForm(forms.Form):
...     url = forms.URLField()
...
>>> form = MyForm({'url': 'www.example.com/http://foo/bar/'})
>>> form.is_valid()
False

http://www.rfc-ref.org/RFC-TEXTS/3986/chapter3.html#sub3

On Fri, Jun 11, 2010 at 3:21 PM, Michael Cetrulo <mail2sa...@gmail.com>wrote:

> looking at the order in which the methods are called on the Field class it
> seems the default "http://"; is added before the validator gets called so
> it should work as expected, don't know where the error in validation was
> coming from.
>
>
> On Fri, Jun 11, 2010 at 2:28 PM, Michael Cetrulo <mail2sa...@gmail.com>wrote:
>
>> hello, something just came up on #django and I think it's worth asking
>> here; turns out current URLValidator
>> http://code.djangoproject.com/browser/django/tags/releases/1.2.1/django/core/validators.py#L41forbids
>>  urls without protocol however the URLField that uses it tries to add
>> a default "http://"; in case it's missing
>> http://code.djangoproject.com/browser/django/tags/releases/1.2.1/django/forms/fields.py#L526
>>
>> the fix is trivial, just change the regex to make the first part optional
>> but I'm not sure if you'll prefer to simply drop that functionality on the
>> widget and reject all those urls to retain compatibility.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to