Opened 5 years ago

Closed 5 years ago

#30551 closed Bug (wontfix)

urlize on URL with incomplete query string adds equal sign.

Reported by: Jochen Garcke Owned by: nobody
Component: Utilities Version: dev
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

Description

If one uses urlize in a template {{ work_urls|urlize }} on URLs such as
http://www.isfdb.org/cgi-bin/pl.cgi?284309
an equal sign will be added
http://www.isfdb.org/cgi-bin/pl.cgi?284309=
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 by Mariusz Felisiak, 5 years ago

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/parse.py", 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 5 years ago by Mariusz Felisiak (previous) (diff)

comment:2 by Mariusz Felisiak, 5 years ago

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