Opened 15 years ago

Closed 15 years ago

#13447 closed (worksforme)

URLField fails validation for a valid URL

Reported by: emson Owned by: nobody
Component: Forms Version: 1.1
Severity: Keywords: fields, urlfield, regex
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The URLField seems to fails validation when it tries to match the following URL:

http://www.awin1.com/cread.php?awinmid=15&awinaffid=81443&clickref=trueblood&p=http%3A%2F%2Fwww.cdwow.com%2FDVD%2Ftrue-blood-series-2%2Fdp%2F8756093%23bc%3Dfbb6

This is an affiliate link that was automatically generated. The problem seems to be occurring when the regular expression matches the second domain i.e. www.cdwow.com%2FDVD
Basically the regex thinks that the second domain shouldn't have a '%' after it so fails.

Can you confirm that this is correct with you?

Thanks
Ben...

Change History (1)

comment:1 by Russell Keith-Magee, 15 years ago

Resolution: worksforme
Status: newclosed

Works for me.

>>> class MyForm(forms.Form):
...     url = forms.URLField()

>>> data = {'url': 'http://www.awin1.com/cread.php?awinmid=15&awinaffid=81443&clickref=trueblood&p=http%3A%2F%2Fwww.cdwow.com%2FDVD%2Ftrue-blood-series-2%2Fdp%2F8756093%23bc%3Dfbb6'}
>>> f = MyForm(data=data)
>>> print f.is_valid()
True
>>> print f.cleaned_data['url']
http://www.awin1.com/cread.php?awinmid=15&awinaffid=81443&clickref=trueblood&p=http%3A%2F%2Fwww.cdwow.com%2FDVD%2Ftrue-blood-series-2%2Fdp%2F8756093%23bc%3Dfbb6
Note: See TracTickets for help on using tickets.
Back to Top