MCPcopy Create free account
hub / github.com/CScorza/IntelOSINT / _extract_balanced_json

Method _extract_balanced_json

IntelOSINT.py:10423–10452  ·  view source on GitHub ↗
(text, start)

Source from the content-addressed store, hash-verified

10421 headers = {"User-Agent": "Mozilla/5.0"}
10422
10423 def _extract_balanced_json(text, start):
10424 if not isinstance(text, str):
10425 return None
10426 if start < 0 or start >= len(text) or text[start] != "{":
10427 return None
10428 depth = 0
10429 in_str = False
10430 escape = False
10431 for i in range(start, len(text)):
10432 ch = text[i]
10433 if in_str:
10434 if escape:
10435 escape = False
10436 continue
10437 if ch == "\\":
10438 escape = True
10439 continue
10440 if ch == '"':
10441 in_str = False
10442 continue
10443 if ch == '"':
10444 in_str = True
10445 continue
10446 if ch == "{":
10447 depth += 1
10448 elif ch == "}":
10449 depth -= 1
10450 if depth == 0:
10451 return text[start:i + 1]
10452 return None
10453
10454 def _extract_share_user_payload(html):
10455 if not isinstance(html, str):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected