Fixed #29627 -- Fixed QueryDict.urlencode() crash with non-string values.
Regression in 7d96f0c49a
.
This commit is contained in:
parent
2e3ba9f592
commit
d8e2be459f
|
@ -511,7 +511,7 @@ class QueryDict(MultiValueDict):
|
||||||
return urlencode({k: v})
|
return urlencode({k: v})
|
||||||
for k, list_ in self.lists():
|
for k, list_ in self.lists():
|
||||||
output.extend(
|
output.extend(
|
||||||
encode(k.encode(self.encoding), v.encode(self.encoding))
|
encode(k.encode(self.encoding), str(v).encode(self.encoding))
|
||||||
for v in list_
|
for v in list_
|
||||||
)
|
)
|
||||||
return '&'.join(output)
|
return '&'.join(output)
|
||||||
|
|
|
@ -11,3 +11,6 @@ Bugfixes
|
||||||
|
|
||||||
* Fixed a race condition in ``QuerySet.update_or_create()`` that could result
|
* Fixed a race condition in ``QuerySet.update_or_create()`` that could result
|
||||||
in data loss (:ticket:`29499`).
|
in data loss (:ticket:`29499`).
|
||||||
|
|
||||||
|
* Fixed a regression where ``QueryDict.urlencode()`` crashed if the dictionary
|
||||||
|
contains a non-string value (:ticket:`29627`).
|
||||||
|
|
|
@ -114,6 +114,13 @@ class QueryDictTests(SimpleTestCase):
|
||||||
self.assertEqual(q.urlencode(), 'next=%2Ft%C3%ABst%26key%2F')
|
self.assertEqual(q.urlencode(), 'next=%2Ft%C3%ABst%26key%2F')
|
||||||
self.assertEqual(q.urlencode(safe='/'), 'next=/t%C3%ABst%26key/')
|
self.assertEqual(q.urlencode(safe='/'), 'next=/t%C3%ABst%26key/')
|
||||||
|
|
||||||
|
def test_urlencode_int(self):
|
||||||
|
# Normally QueryDict doesn't contain non-string values but lazily
|
||||||
|
# written tests may make that mistake.
|
||||||
|
q = QueryDict(mutable=True)
|
||||||
|
q['a'] = 1
|
||||||
|
self.assertEqual(q.urlencode(), 'a=1')
|
||||||
|
|
||||||
def test_mutable_copy(self):
|
def test_mutable_copy(self):
|
||||||
"""A copy of a QueryDict is mutable."""
|
"""A copy of a QueryDict is mutable."""
|
||||||
q = QueryDict().copy()
|
q = QueryDict().copy()
|
||||||
|
|
Loading…
Reference in New Issue