From 6f55ea5998fe61ecce446a092094fb0b0662931e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Fri, 10 Jul 2026 09:03:54 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20base64=20padding=20=D0=B8=20+=E2=86=92?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B1=D0=B5=D0=BB,=20v1.0.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/site/app.py b/site/app.py index 9f0be6a..ef3a50f 100644 --- a/site/app.py +++ b/site/app.py @@ -4,7 +4,7 @@ from flask import Flask, render_template, request app = Flask(__name__) -VERSION = '1.0.3' +VERSION = '1.0.4' @app.route('/') @@ -27,6 +27,12 @@ def upload(): # убрать префикс data:...;base64, if ',' in data: data = data.split(',', 1)[1] + # form-encode превращает + в пробелы — восстановить + data = data.replace(' ', '+') + # добавить padding если потерялся + missing = len(data) % 4 + if missing: + data += '=' * (4 - missing) raw = base64.b64decode(data) elapsed = round((time.time() - t0) * 1000) return {'ok': True, 'bytes': len(raw), 'elapsed_ms': elapsed}