bizydraft 0.2.53__py3-none-any.whl → 0.2.54__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bizydraft might be problematic. Click here for more details.
- bizydraft/oss_utils.py +22 -0
- {bizydraft-0.2.53.dist-info → bizydraft-0.2.54.dist-info}/METADATA +1 -1
- {bizydraft-0.2.53.dist-info → bizydraft-0.2.54.dist-info}/RECORD +5 -5
- {bizydraft-0.2.53.dist-info → bizydraft-0.2.54.dist-info}/WHEEL +0 -0
- {bizydraft-0.2.53.dist-info → bizydraft-0.2.54.dist-info}/top_level.txt +0 -0
bizydraft/oss_utils.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import base64
|
|
2
2
|
import json
|
|
3
3
|
import os
|
|
4
|
+
import re
|
|
5
|
+
import uuid
|
|
4
6
|
from http.cookies import SimpleCookie
|
|
7
|
+
from pathlib import Path
|
|
5
8
|
from time import time
|
|
6
9
|
from typing import Any, Dict
|
|
7
10
|
|
|
@@ -177,6 +180,10 @@ async def upload_to_oss(post, api_key: str):
|
|
|
177
180
|
if not filename:
|
|
178
181
|
return web.Response(status=400)
|
|
179
182
|
|
|
183
|
+
should_clean, filename = clean_filename(filename)
|
|
184
|
+
if should_clean:
|
|
185
|
+
filename = f"{uuid.uuid4()}.{filename}"
|
|
186
|
+
|
|
180
187
|
oss_token = await get_upload_token(filename, api_key)
|
|
181
188
|
result = await upload_filefield_to_oss(image, oss_token)
|
|
182
189
|
if result["status"] != 200:
|
|
@@ -225,3 +232,18 @@ async def upload_image(request):
|
|
|
225
232
|
return web.Response(status=403, text="No validated key found")
|
|
226
233
|
post = await request.post()
|
|
227
234
|
return await upload_to_oss(post, api_key)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _should_clean(name: str) -> bool:
|
|
238
|
+
"""True -> 乱码;False -> 正常"""
|
|
239
|
+
# 主名部分含 URL 参数符号且最后有扩展名
|
|
240
|
+
return bool(re.search(r"[&=,].+\.[\w]+$", name))
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def clean_filename(bad: str) -> (bool, str):
|
|
244
|
+
"""对乱码串提取最后扩展名;正常串直接返回原值"""
|
|
245
|
+
if not _should_clean(bad):
|
|
246
|
+
return False, bad
|
|
247
|
+
# 提取最后扩展名(含点)
|
|
248
|
+
ext = re.search(r"(\.[\w]+)$", bad)
|
|
249
|
+
return True, ext.group(1) if ext else bad # 理论上不会没有扩展名
|
|
@@ -3,7 +3,7 @@ bizydraft/block_nodes.py,sha256=Lqn3oSCaGDHR2OICc8a2iRoRCVVK9v1-9MM3r-qIZgA,1092
|
|
|
3
3
|
bizydraft/env.py,sha256=nVh4xBKXWnRUPbHL3PqZr6VFN8txKsrsmshu8PFGaqo,299
|
|
4
4
|
bizydraft/hijack_nodes.py,sha256=ktonkuI3NEctELUL9C0Hmv2-DaDr1MClGZWeHrP2VCA,3485
|
|
5
5
|
bizydraft/hijack_routes.py,sha256=lf6x3xDzbo9yQIRwfG_1oxcUNfrX_1ogbiff3WOV9gM,3268
|
|
6
|
-
bizydraft/oss_utils.py,sha256=
|
|
6
|
+
bizydraft/oss_utils.py,sha256=FxTe9TxA9Q13pxKaOpcN0Jui-BG1SBWySM71PqpIlsM,8601
|
|
7
7
|
bizydraft/patch_handlers.py,sha256=WPf4xeV5sBpoJ2MkHHhx0wem7B0KQNuhONElN7c9v3g,5989
|
|
8
8
|
bizydraft/postload.py,sha256=XFElKcmCajT_oO7SVJJBaN04XcWro54N5HB5cSCxfvI,1308
|
|
9
9
|
bizydraft/prestartup_patch.py,sha256=4FGjmRcDHELjtlQOrfTfk2Un5OS89QIqfq-gEcB9WDs,998
|
|
@@ -22,7 +22,7 @@ bizydraft/static/js/postEvent.js,sha256=met19YcUlC8ttKQl9tHJ66NnfltBeOeq28TZBmIG
|
|
|
22
22
|
bizydraft/static/js/socket.js,sha256=VE3fTAgEfM0FZhL526Skt7OCRokOa3mzTCAjAomI_tE,2432
|
|
23
23
|
bizydraft/static/js/tool.js,sha256=VupamUuh7tYiDnBTrL5Z_yLmhJinskhzRXwE3zfsKZM,2901
|
|
24
24
|
bizydraft/static/js/uploadFile.js,sha256=WvglKzHMeOzDhOH3P-fLcPHxCLbKOJpo4DntoRxeJtI,4908
|
|
25
|
-
bizydraft-0.2.
|
|
26
|
-
bizydraft-0.2.
|
|
27
|
-
bizydraft-0.2.
|
|
28
|
-
bizydraft-0.2.
|
|
25
|
+
bizydraft-0.2.54.dist-info/METADATA,sha256=9HHnNfSi145FUtWlkBxdSa4UcipPMuRe7aBCl6N2ENA,162
|
|
26
|
+
bizydraft-0.2.54.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
27
|
+
bizydraft-0.2.54.dist-info/top_level.txt,sha256=XtoBq6hjZhXIM7aas4GtPDtAiKo8FdLzMABXW8qqQ8M,10
|
|
28
|
+
bizydraft-0.2.54.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|