628: Allow internal bug_tracker URLs (unqualified hostnames)

timw.a******@gmai***** (Google Code) (Is this you? Claim this profile.)
Nov. 13, 2008
Describe the enhancement and the motivation for it.
The repository editor currently prohibits 'http://bugs/%s'. Looking in the
django code, this is caused by URLField's insistence on a fully-qualified
domain name (with two or more components).

What operating system are you using? What browser?
Linux (Ubuntu 8.04 32-bit), Firefox 3.0

Please provide any additional information below.
The problem is with url_re. Below is a modified version that is less strict
about domain matching (django/forms/fields.py line 523).

url_re = re.compile(
    r'^https?://' # http:// or https://
    r'(?:(?:[A-Z0-9_-]+\.)*(?:[A-Z_][A-Z0-9_-]*)|' #domain...
    r'localhost|' #localhost...
    r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
    r'(?::\d+)?' # optional port
    r'(?:/?|/.+)$', re.IGNORECASE)
chipx86
#1 chipx86
Can you submit this as a patch on http://reviews.reivew-board.org ?
  • +Component-SCMTools
#2 timw.a******@gmai***** (Google Code) (Is this you? Claim this profile.)
I doubt I'd be able to: it's a patch to django's source. It looks like they have a
ticket filed already: http://code.djangoproject.com/ticket/7969

Another local fix could be to mark that field as a string field and let site
administrators be smart about their own requirements (this would also alleviate other
restrictions I notice in django's tracker about URLField rejecting real domains).

I will post a review of the latter suggestion: switching to CharField.
chipx86
#3 chipx86
Oh I see. Yeah, that's a shame.

Maybe it's time to introduce a URIField. We've been needing something more flexible
than URLField to support non-http(s) URIs, and while we're at it we should allow for
non-fully-qualified domains.
chipx86
#4 chipx86
Fixed in r1571.
  • +Fixed