[Django] #30551: urlize on URL with incomplete query string adds equal sign

4 views
Skip to first unread message

Django

unread,
Jun 7, 2019, 2:35:34 AM6/7/19
to django-...@googlegroups.com
#30551: urlize on URL with incomplete query string adds equal sign
-----------------------------------------+------------------------
Reporter: jochengcd | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/30551>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 7, 2019, 4:54:34 AM6/7/19
to django-...@googlegroups.com
#30551: urlize on URL with incomplete query string adds equal sign.
-------------------------------+--------------------------------------

Reporter: jochengcd | Owner: nobody
Type: Uncategorized | Status: new
Component: Utilities | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by felixxm):

* version: 1.11 => master
* component: Uncategorized => Utilities


Comment:

Thanks for the report.
[https://github.com/django/django/blob/c498f088c584ec3aff97409fdc11b39b28240de9/django/utils/html.py#L220-L223
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, hence I believe that query string
used by this site is incorrect. I'm not sure that we should handle this
case in Django.

--
Ticket URL: <https://code.djangoproject.com/ticket/30551#comment:1>

Django

unread,
Jun 7, 2019, 5:18:27 AM6/7/19
to django-...@googlegroups.com
#30551: urlize on URL with incomplete query string adds equal sign.
---------------------------+--------------------------------------
Reporter: jochengcd | Owner: nobody
Type: Bug | Status: closed
Component: Utilities | Version: master
Severity: Normal | Resolution: wontfix

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------+--------------------------------------
Changes (by felixxm):

* status: new => closed
* type: Uncategorized => Bug
* resolution: => wontfix


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/30551#comment:2>

Reply all
Reply to author
Forward
0 new messages