From: Javier Sagredo Date: Thu, 18 Jun 2026 22:26:09 +0000 (+0200) Subject: Fix correctness, robustness, and tooling issues from code review X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=e2aa1bdb1d82ce0c5a4111aaa73d1ac4d30c71ad;p=classgraph.git Fix correctness, robustness, and tooling issues from code review Render: escape `<` to < in the embedded JSON so a `` in any string (e.g. a Haddock comment) can't close the data @ (e.g. inside a Haddock comment) would otherwise close the +-- script element early and corrupt — or inject into — the page. Inside a +-- JSON string @\\u003c@ decodes back to @<@; outside strings @<@ never +-- appears in JSON, so replacing the byte unconditionally is safe and keeps +-- the document valid. @<@ is ASCII (0x3c) and cannot occur inside a UTF-8 +-- multibyte sequence, so a byte-level rewrite is correct. +escapeForScript :: BL.ByteString -> BL.ByteString +escapeForScript = BL.concatMap esc + where + esc 0x3c = BL.pack [0x5c, 0x75, 0x30, 0x30, 0x33, 0x63] -- "<" + esc c = BL.singleton c + ------------------------------------------------------------------------------ -- Substitution helper