From ec1f4dc2845956e4237610e29ebad65b544ea095 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 26 May 2022 16:13:31 +0100 Subject: [PATCH] Image check in lambda handler --- combineImg/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/combineImg/__init__.py b/combineImg/__init__.py index 229377f..a341f16 100644 --- a/combineImg/__init__.py +++ b/combineImg/__init__.py @@ -117,6 +117,9 @@ def genImageFromURL(urlArray): def lambda_handler(event, context): images = event["queryStringParameters"].get("imgs","").split(",") + for img in images: + if not img.startswith("https://pbs.twimg.com"): + return {'statusCode':400,'body':'Invalid image URL'} combined = genImageFromURL(images) buffered = BytesIO() combined.save(buffered,format="JPEG",quality=60)