Skip to content

Commit e522602

Browse files
authored
Python: Update to use unquote_plus for parsing instead of unquote. (#7569)
* Updating python to use unquote_plus for parsing instead of unquote as best practice.
1 parent 1d0d3bc commit e522602

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

python/cross_service/apigateway_covid-19_tracker/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def state_cases(state):
106106
logger.info("Got %s to /states/%s.", app.current_request.method, state)
107107
logger.info("JSON body: %s", app.current_request.json_body)
108108

109-
state = urllib.parse.unquote(state)
109+
state = urllib.parse.unquote_plus(state)
110110
verify_input(state, data=app.current_request.json_body)
111111

112112
response = None
@@ -145,8 +145,8 @@ def state_date_cases(state, date):
145145
"""
146146
logger.info("Got %s to /states/%s/%s.", app.current_request.method, state, date)
147147

148-
state = urllib.parse.unquote(state)
149-
date = urllib.parse.unquote(date)
148+
state = urllib.parse.unquote_plus(state)
149+
date = urllib.parse.unquote_plus(date)
150150
verify_input(state, date=date)
151151

152152
response = None

python/example_code/s3/s3_versioning/remove_delete_marker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def lambda_handler(event, context):
4141
task_id = task["taskId"]
4242

4343
try:
44-
obj_key = parse.unquote(task["s3Key"], encoding="utf-8")
44+
obj_key = parse.unquote_plus(task["s3Key"], encoding="utf-8")
4545
obj_version_id = task["s3VersionId"]
4646
bucket_name = task["s3BucketArn"].split(":")[-1]
4747

python/example_code/s3/s3_versioning/revise_stanza.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def lambda_handler(event, context):
3939
task = event["tasks"][0]
4040
task_id = task["taskId"]
4141
# The revision type is packed with the object key as a pipe-delimited string.
42-
obj_key, revision = parse.unquote(task["s3Key"], encoding="utf-8").split("|")
42+
obj_key, revision = parse.unquote_plus(task["s3Key"], encoding="utf-8").split("|")
4343
bucket_name = task["s3BucketArn"].split(":")[-1]
4444

4545
logger.info("Got task: apply revision %s to %s.", revision, obj_key)

0 commit comments

Comments
 (0)