Opened 3 years ago

Closed 3 years ago

#18178 closed Bug (wontfix)

URLField -- TLD part can not start/end with hyphen

Reported by: mila Owned by: nobody
Component: Forms Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

URLField accepts URLs where a TLD part of the domain name starts or ends with a hyphen.

>>> URLField().clean("example.-com")
u'http://example.-com/'
>>> URLField().clean("example.com-")
u'http://example.com-/'

Change History (3)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

The concept of what is and what isn't an URL isn't very well defined. The regexp given by the RFC matches absolutely anything (see https://code.djangoproject.com/ticket/9202#comment:4).

I'm not excited by the idea of tweaking the current validation...

comment:2 Changed 3 years ago by adrian

Our implementation uses Python's urlparse.urlsplit(), which allows that. Not sure whether that should be considered a bug in the Python standard library.

comment:3 Changed 3 years ago by claudep

  • Resolution set to wontfix
  • Status changed from new to closed

I think the current validation is already doing a good job. Reopen if a you can provide a patch which doesn't complicate things too much.

Note: See TracTickets for help on using tickets.
Back to Top