Browse Source

fix-parser-b64-try-catch

master
Serge Shutov 2 weeks ago
parent
commit
47236246a5
  1. 2
      content/parser.js

2
content/parser.js

@ -59,7 +59,7 @@ function parseOne(text, startIdx) {
const closeIdx = text.indexOf(CLOSE_B64, startIdx + OPEN_B64.length); const closeIdx = text.indexOf(CLOSE_B64, startIdx + OPEN_B64.length);
if (closeIdx < 0) return null; if (closeIdx < 0) return null;
const raw = text.slice(startIdx + OPEN_B64.length, closeIdx); const raw = text.slice(startIdx + OPEN_B64.length, closeIdx);
const json = b64DecodeUtf8(raw); let json = null; try { json = b64DecodeUtf8(raw); } catch (e) { return null; }
const obj = tryParseJson(json); const obj = tryParseJson(json);
if (!obj || typeof obj !== 'object' || !obj.tool) return null; if (!obj || typeof obj !== 'object' || !obj.tool) return null;
return { call: obj, nextIdx: closeIdx + CLOSE_B64.length }; return { call: obj, nextIdx: closeIdx + CLOSE_B64.length };

Loading…
Cancel
Save