Opened 4 months ago

Closed 4 months ago

#30551 closed Bug (wontfix)

urlize on URL with incomplete query string adds equal sign.

Reported by: jochengcd Owned by: nobody
Component: Utilities Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If one uses urlize in a template {{ work_urls|urlize }} on URLs such as
an equal sign will be added
The resulting URL fails at that site.

Granted, I suspect that this is likely not a standard conform use of '?' by that site, but still unwanted behaviour.

Change History (2)

comment:1 Changed 4 months ago by felixxm

Component: UncategorizedUtilities
Summary: urlize on URL with incomplete query string adds equal signurlize on URL with incomplete query string adds equal sign.
Version: 1.11master

Thanks for the report. smart_urlquote() adds a trailing equal sign. I noticed that parse_qsl() raises:

  File "/usr/lib/python3.6/urllib/", line 693, in parse_qsl
    raise ValueError("bad query field: %r" % (name_value,))
ValueError: bad query field: '284309'

when we add strict_parsing=True flag. I know that theoretically it is valid but still an edge case IMO. I'm not sure that we should handle this case in Django.

Last edited 4 months ago by felixxm (previous) (diff)

comment:2 Changed 4 months ago by felixxm

Resolution: wontfix
Status: newclosed
Type: UncategorizedBug

It seems that a patch is not feasible with the current implementation that uses parse_qsl(), because

>>> parse_qsl('a', keep_blank_values=True)
[('a', '')]
>>> parse_qsl('a=', keep_blank_values=True)
[('a', '')]

so would have to add a special workaround for this single case, what is not worth it.

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