mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
tracker.py: Ensure /click endpoint doesn't modify destination urls
Omitting `keep_blank_values` was dropping blank query parameters. Furthermore, converting the output of `parse_qsl` to a dictionary was unnecessarily modifying the order of parameters since dicts are not ordered. Fortunately `urllib.urlencode` also accepts a sequence of two-element tuples and the order of parameters in the encoded string will match the order of parameter tuples in the sequence.
This commit is contained in:
@@ -173,10 +173,10 @@ def event_click():
|
||||
|
||||
def _fix_query_encoding(parse_result):
|
||||
"Fix encoding in the query string."
|
||||
query_dict = dict(parse_qsl(parse_result.query))
|
||||
query_params = parse_qsl(parse_result.query, keep_blank_values=True)
|
||||
|
||||
# this effectively calls urllib.quote_plus on every query value
|
||||
return parse_result._replace(query=urllib.urlencode(query_dict))
|
||||
return parse_result._replace(query=urllib.urlencode(query_params))
|
||||
|
||||
|
||||
def _redirect_nocache(destination):
|
||||
|
||||
Reference in New Issue
Block a user