Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unquote paths #188

Merged
merged 9 commits into from
Oct 16, 2020
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/apig_wsgi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import urllib
from base64 import b64decode, b64encode
from collections import defaultdict
from io import BytesIO
Expand Down Expand Up @@ -69,7 +70,7 @@ def get_environ_v1(event, context, binary_support):
environ = {
"CONTENT_LENGTH": str(len(body)),
"HTTP": "on",
"PATH_INFO": event["path"],
"PATH_INFO": urllib.parse.unquote_to_bytes(event["path"]).decode("iso-8859-1"),
"REMOTE_ADDR": "127.0.0.1",
"REQUEST_METHOD": event["httpMethod"],
"SCRIPT_NAME": "",
Expand Down Expand Up @@ -134,11 +135,12 @@ def get_environ_v2(event, context, binary_support):
body = get_body(event)
headers = event["headers"]
http = event["requestContext"]["http"]

environ = {
"CONTENT_LENGTH": str(len(body)),
"HTTP": "on",
"HTTP_COOKIE": ";".join(event.get("cookies", ())),
"PATH_INFO": http["path"],
"PATH_INFO": urllib.parse.unquote_to_bytes(http["path"]).decode("iso-8859-1"),
"QUERY_STRING": event["rawQueryString"],
"REMOTE_ADDR": http["sourceIp"],
"REQUEST_METHOD": http["method"],
Expand Down