Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Agent requests: text with a broken character pair is refused at the entry with the reason

Bowen Xuee2a227471ed0
diff --git a/freevideo_engine/agent/editor_runtime.py b/freevideo_engine/agent/editor_runtime.py
index 2f793a3..3d4c42c 100644
--- a/freevideo_engine/agent/editor_runtime.py
+++ b/freevideo_engine/agent/editor_runtime.py
@@ -319,6 +319,11 @@ class ScriptRuntime:
return context
def _text(self, name, request):
+ try:
+ request.encode('utf-8')
+ except UnicodeEncodeError:
+ # QuickJS ends the whole program on half of a character pair, wherever the text came from.
+ raise ValueError('The text holds half of a character pair') from None
with self._lock:
if self._context is None:
self._context = self._fresh()
diff --git a/freevideo_engine/agent/routes.py b/freevideo_engine/agent/routes.py
index 3a9af4a..e7dd090 100644
--- a/freevideo_engine/agent/routes.py
+++ b/freevideo_engine/agent/routes.py
@@ -623,7 +623,20 @@ def register():
data.extend(chunk)
if len(data) > limit:
raise JobError('too_large', 'Body exceeds limit', limit_bytes=limit)
- return json.loads(data.decode('utf-8'), parse_constant=lambda _: (_ for _ in ()).throw(json.JSONDecodeError('Nonfinite JSON', '', 0)))
+ text = data.decode('utf-8')
+ value = json.loads(text, parse_constant=lambda _: (_ for _ in ()).throw(json.JSONDecodeError('Nonfinite JSON', '', 0)))
+ if '\\u' in text:
+ # An escape may spell half of a character pair. No file or page can hold that text, and the
+ # script runtime behind the editing rules ends the whole program on it.
+ try:
+ json.dumps(value, ensure_ascii=False).encode('utf-8')
+ except UnicodeEncodeError:
+ row = contract.diagnostic('/', 'text made of whole characters', None)
+ row.update(got='half of a character pair', next='Send whole characters and retry.',
+ message='The body holds half of a character pair (a lone \\ud800 to \\udfff escape); '
+ 'no text can be stored that way.')
+ raise specs.SpecError(row) from None
+ return value
async def body(request, **ignored):
return request[body_key]