File tree 2 files changed +35
-2
lines changed
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -2768,7 +2768,37 @@ def test_wsgi_query_string_unquoted(self):
2768
2768
"requestContext" : {},
2769
2769
}
2770
2770
request = create_wsgi_request (event )
2771
- self .assertEqual (request ["QUERY_STRING" ], "a=A,B&b=C#D" )
2771
+ expected = "a=A%2CB&b=C%23D" # unencoded result: "a=A,B&b=C#D"
2772
+ self .assertEqual (request ["QUERY_STRING" ], expected )
2773
+
2774
+ def test_wsgi_query_string_ampersand_unencoded (self ):
2775
+ event = {
2776
+ "body" : None ,
2777
+ "headers" : {},
2778
+ "pathParameters" : {},
2779
+ "path" : "/path/path1" ,
2780
+ "httpMethod" : "GET" ,
2781
+ "queryStringParameters" : {
2782
+ "test" : "M&M" ,
2783
+ },
2784
+ "requestContext" : {},
2785
+ }
2786
+ request = create_wsgi_request (event )
2787
+ self .assertEqual (request ["QUERY_STRING" ], "test=M%26M" )
2788
+
2789
+ def test_wsgi_query_string_with_encodechars (self ):
2790
+ event = {
2791
+ "body" : None ,
2792
+ "headers" : {},
2793
+ "pathParameters" : {},
2794
+ "path" : "/path/path1" ,
2795
+ "httpMethod" : "GET" ,
2796
+ "queryStringParameters" : {"query" : "Jane&John" , "otherquery" : "B" , "test" : "hello+m.te&how&are&you" },
2797
+ "requestContext" : {},
2798
+ }
2799
+ request = create_wsgi_request (event )
2800
+ expected = "query=Jane%26John&otherquery=B&test=hello%2Bm.te%26how%26are%26you"
2801
+ self .assertEqual (request ["QUERY_STRING" ], expected )
2772
2802
2773
2803
2774
2804
if __name__ == "__main__" :
Original file line number Diff line number Diff line change @@ -36,13 +36,16 @@ def create_wsgi_request(
36
36
# we have to check for the existence of one and then fall back to the
37
37
# other.
38
38
39
+ # Assumes that the lambda event provides the unencoded string as
40
+ # the value in "queryStringParameters"/"multiValueQueryStringParameters"
41
+ # The QUERY_STRING value provided to WSGI expects the query string to be properly urlencoded.
42
+ # See https://github.com/zappa/Zappa/issues/1227 for discussion of this behavior.
39
43
if "multiValueQueryStringParameters" in event_info :
40
44
query = event_info ["multiValueQueryStringParameters" ]
41
45
query_string = urlencode (query , doseq = True ) if query else ""
42
46
else :
43
47
query = event_info .get ("queryStringParameters" , {})
44
48
query_string = urlencode (query ) if query else ""
45
- query_string = unquote (query_string )
46
49
47
50
if context_header_mappings :
48
51
for key , value in context_header_mappings .items ():
You can’t perform that action at this time.
0 commit comments