Updated image combine logic for checking hosts
This commit is contained in:
parent
9493004920
commit
b4a55e2a53
@ -4,6 +4,7 @@ from io import BytesIO
|
|||||||
import base64
|
import base64
|
||||||
import concurrent.futures
|
import concurrent.futures
|
||||||
from time import time as timer
|
from time import time as timer
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
# find the highest res image in an array of images
|
# find the highest res image in an array of images
|
||||||
def findImageWithMostPixels(imageArray):
|
def findImageWithMostPixels(imageArray):
|
||||||
@ -139,10 +140,11 @@ def lambda_handler(event, context):
|
|||||||
"body": "Invalid request."
|
"body": "Invalid request."
|
||||||
}
|
}
|
||||||
images = event["queryStringParameters"].get("imgs","").split(",")
|
images = event["queryStringParameters"].get("imgs","").split(",")
|
||||||
for img in images:
|
for img in imgs:
|
||||||
if not img.startswith("https://pbs.twimg.com"):
|
result = urlparse(img)
|
||||||
return {'statusCode':400,'body':'Invalid image URL'}
|
if result.hostname != "pbs.twimg.com" or result.scheme != "https":
|
||||||
combined = genImageFromURL(images)
|
abort(400)
|
||||||
|
combined = genImageFromURL(images)
|
||||||
if (combined == None):
|
if (combined == None):
|
||||||
return {'statusCode':200,'body':get500ImgBase64(),'isBase64Encoded':True,'headers':{"Content-Type": "image/jpeg","Cache-Control": "public, max-age=86400"}}
|
return {'statusCode':200,'body':get500ImgBase64(),'isBase64Encoded':True,'headers':{"Content-Type": "image/jpeg","Cache-Control": "public, max-age=86400"}}
|
||||||
buffered = BytesIO()
|
buffered = BytesIO()
|
||||||
|
@ -17,6 +17,7 @@ from yt_dlp.utils import ExtractorError
|
|||||||
import vxlogging as log
|
import vxlogging as log
|
||||||
import zipfile
|
import zipfile
|
||||||
import html
|
import html
|
||||||
|
from urllib.parse import urlparse
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
user_agent=""
|
user_agent=""
|
||||||
@ -360,7 +361,8 @@ def rendercombined():
|
|||||||
abort(400)
|
abort(400)
|
||||||
#check that each image starts with "https://pbs.twimg.com"
|
#check that each image starts with "https://pbs.twimg.com"
|
||||||
for img in imgs:
|
for img in imgs:
|
||||||
if not img.startswith("https://pbs.twimg.com"):
|
result = urlparse(img)
|
||||||
|
if result.hostname != "pbs.twimg.com" or result.scheme != "https":
|
||||||
abort(400)
|
abort(400)
|
||||||
finalImg= combineImg.genImageFromURL(imgs)
|
finalImg= combineImg.genImageFromURL(imgs)
|
||||||
imgIo = BytesIO()
|
imgIo = BytesIO()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user