Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
URLValidator on urls without protocol
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Cetrulo  
View profile  
 More options Jun 11 2010, 1:28 pm
From: Michael Cetrulo <mail2sa...@gmail.com>
Date: Fri, 11 Jun 2010 14:28:54 -0300
Local: Fri, Jun 11 2010 1:28 pm
Subject: URLValidator on urls without protocol

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/djan...
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/djan...

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Cetrulo  
View profile  
 More options Jun 11 2010, 2:21 pm
From: Michael Cetrulo <mail2sa...@gmail.com>
Date: Fri, 11 Jun 2010 15:21:59 -0300
Local: Fri, Jun 11 2010 2:21 pm
Subject: Re: URLValidator on urls without protocol

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Cetrulo  
View profile  
 More options Jun 11 2010, 6:02 pm
From: Michael Cetrulo <mail2sa...@gmail.com>
Date: Fri, 11 Jun 2010 19:02:35 -0300
Local: Fri, Jun 11 2010 6:02 pm
Subject: Re: URLValidator on urls without protocol

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MIL  
View profile  
 More options Jun 12 2010, 6:42 am
From: MIL <needb...@gmail.com>
Date: Sat, 12 Jun 2010 03:42:59 -0700 (PDT)
Local: Sat, Jun 12 2010 6:42 am
Subject: Re: URLValidator on urls without protocol
I was the guy that brought it up on #django
And I would like to follow this thread.

Thanks :o)

Michael Hjulskov


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Cetrulo  
View profile  
 More options Jun 20 2010, 9:35 pm
From: Michael Cetrulo <mail2sa...@gmail.com>
Date: Sun, 20 Jun 2010 22:35:23 -0300
Local: Sun, Jun 20 2010 9:35 pm
Subject: Re: URLValidator on urls without protocol

ticket: http://code.djangoproject.com/ticket/13804

also found a real-life scenario when this feature of the RFC is implemented,
the site reddit.com uses it for a shortcut that searchs/submits links to
their website, example:
http://www.reddit.com/s/http://code.djangoproject.com/ticket/13804


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jared Martin  
View profile  
 More options Nov 18 2012, 12:21 am
From: Jared Martin <jaredtmar...@gmail.com>
Date: Sat, 17 Nov 2012 21:21:11 -0800 (PST)
Local: Sun, Nov 18 2012 12:21 am
Subject: Re: URLValidator on urls without protocol

I don't mean to wake a dead dog, but what has become of this? I came across
this problem today. For now, I've subclassed. But it should be fixed, right?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karen Tracey  
View profile  
 More options Nov 18 2012, 12:33 am
From: Karen Tracey <kmtra...@gmail.com>
Date: Sun, 18 Nov 2012 00:32:46 -0500
Local: Sun, Nov 18 2012 12:32 am
Subject: Re: URLValidator on urls without protocol

On Sun, Nov 18, 2012 at 12:21 AM, Jared Martin <jaredtmar...@gmail.com>wrote:

> I don't mean to wake a dead dog, but what has become of this? I came
> across this problem today. For now, I've subclassed. But it should be
> fixed, right?

Yes, it should be fixed. Per the ticket referenced it was fixed two years
ago. The specific scenario showin in the ticket is fixed:

Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import django
>>> django.get_version()
'1.4.2'
>>> from django.forms import URLField
>>> f = URLField()
>>> f.clean('www.example.com/://')

u'http://www.example.com/://'


So what do you mean, exactly, that you came across it today? What exactly
is failing unexpectedly and on what version of Django?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jared Martin  
View profile  
 More options Nov 18 2012, 12:34 am
From: Jared Martin <jaredtmar...@gmail.com>
Date: Sat, 17 Nov 2012 23:34:20 -0600
Local: Sun, Nov 18 2012 12:34 am
Subject: Re: URLValidator on urls without protocol

Yes it indeed was. That was a mistake on my part. I saw it as soon as I submitted. Sorry.

On Nov 17, 2012, at 11:32 PM, Karen Tracey <kmtra...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »