From 259022260af15b0d560c683d5f48969937a7e8c7 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Wed, 23 Oct 2024 10:39:16 +0100 Subject: [PATCH] Simplify query string parsing --- lambdas/handlers/edge_presign_handler.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lambdas/handlers/edge_presign_handler.py b/lambdas/handlers/edge_presign_handler.py index bd4e33992..bd9c9de74 100644 --- a/lambdas/handlers/edge_presign_handler.py +++ b/lambdas/handlers/edge_presign_handler.py @@ -1,6 +1,7 @@ import hashlib import json import logging +from urllib.parse import parse_qs from enums.lambda_error import LambdaError from services.edge_presign_service import EdgePresignService @@ -46,10 +47,7 @@ def lambda_handler(event, context): raise CloudFrontEdgeException(500, LambdaError.EdgeNoOrigin) try: - query_params = { - k: v - for k, v in (x.split("=") for x in querystring.split("&") if "=" in x) - } + query_params = {k: v[0] for k, v in parse_qs(querystring).items()} except ValueError: logger.error(f"Malformed query string: {querystring}") raise CloudFrontEdgeException(500, LambdaError.EdgeMalformedQuery)