Skip to content

Commit 58c22fa

Browse files
committed
always encode query parameters in sorted order
1 parent fccd35e commit 58c22fa

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

roundup/cgi/actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ def handle(self):
12211221
redirect_url_tuple.netloc,
12221222
redirect_url_tuple.path,
12231223
redirect_url_tuple.params,
1224-
urllib_.urlencode(query, doseq=True),
1224+
urllib_.urlencode(list(sorted(query.items())), doseq=True),
12251225
redirect_url_tuple.fragment)
12261226
)
12271227

@@ -1239,7 +1239,7 @@ def handle(self):
12391239
redirect_url_tuple.netloc,
12401240
redirect_url_tuple.path,
12411241
redirect_url_tuple.params,
1242-
urllib_.urlencode(query, doseq=True),
1242+
urllib_.urlencode(list(sorted(query.items())), doseq=True),
12431243
redirect_url_tuple.fragment )
12441244
)
12451245
raise exceptions.Redirect(redirect_url)

test/test_actions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def opendb(username):
325325

326326
# test if we are logged out; should kill the @action=logout
327327
self.form.value[:] = [] # clear out last test's setup values
328-
self.assertLoginRaisesRedirect("http://whoami.com/path/issue39?%40startwith=0&%40pagesize=50",
328+
self.assertLoginRaisesRedirect("http://whoami.com/path/issue39?%40pagesize=50&%40startwith=0",
329329
'foo', 'right', "http://whoami.com/path/issue39?@action=logout&@pagesize=50&@startwith=0")
330330

331331
def testInvalidLoginRedirect(self):
@@ -336,12 +336,12 @@ def opendb(username):
336336
self.client.opendb = opendb
337337

338338
# basic test with query
339-
self.assertLoginRaisesRedirect("http://whoami.com/path/issue?%40error_message=Invalid+login&%40action=search",
339+
self.assertLoginRaisesRedirect("http://whoami.com/path/issue?%40action=search&%40error_message=Invalid+login",
340340
'foo', 'wrong', "http://whoami.com/path/issue?@action=search")
341341

342342
# test that old messages are removed
343343
self.form.value[:] = [] # clear out last test's setup values
344-
self.assertLoginRaisesRedirect("http://whoami.com/path/issue?%40error_message=Invalid+login&%40action=search",
344+
self.assertLoginRaisesRedirect("http://whoami.com/path/issue?%40action=search&%40error_message=Invalid+login",
345345
'foo', 'wrong', "http://whoami.com/path/issue?@action=search&@ok_messagehurrah+we+win&@error_message=blam")
346346

347347
# test when there is no __came_from specified

0 commit comments

Comments
 (0)