mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-01 14:43:39 +00:00
fix(ui): localize expired pairing QR notice
This commit is contained in:
@@ -1702,16 +1702,19 @@ const MAX_JSON_AUTOPARSE_CHARS = 20_000;
|
||||
* Size-capped to prevent render-loop DoS from large JSON messages.
|
||||
*/
|
||||
function detectJson(text: string): { parsed: unknown; pretty: string } | null {
|
||||
const t = text.trim();
|
||||
const trimmed = text.trim();
|
||||
|
||||
// Enforce size cap to prevent UI freeze from multi-MB JSON payloads
|
||||
if (t.length > MAX_JSON_AUTOPARSE_CHARS) {
|
||||
if (trimmed.length > MAX_JSON_AUTOPARSE_CHARS) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ((t.startsWith("{") && t.endsWith("}")) || (t.startsWith("[") && t.endsWith("]"))) {
|
||||
if (
|
||||
(trimmed.startsWith("{") && trimmed.endsWith("}")) ||
|
||||
(trimmed.startsWith("[") && trimmed.endsWith("]"))
|
||||
) {
|
||||
try {
|
||||
const parsed = JSON.parse(t);
|
||||
const parsed = JSON.parse(trimmed);
|
||||
return { parsed, pretty: JSON.stringify(parsed, null, 2) };
|
||||
} catch {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user