{"record":{"id":"a0695b5c25ea0152","repo":"jdx/mise","slug":"impossible-to-find-at-least-two-unused-byte-codes","errorCode":null,"errorMessage":"Impossible to find at least two unused byte codes in this HTML-code. We need it to escape bracket-contained placeholders inside tags.","messagePattern":"Impossible to find at least two unused byte codes in this HTML-code\\. We need it to escape bracket-contained placeholders inside tags\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/vfox/lua/htmlparser.lua","lineNumber":88,"sourceCode":"\t\t\t\t\tdbg(\"%s\",str(busy[i]))\n\t\t\t\telse -- if < or >\n\t\t\t\t\tdbg(\"[FindPH]:#LINE# Done!\",i)\n\t\t\t\t\tbreak\n\t\t\t\tend -- if < or > -- }}}\n\t\t\telse -- text!match(cc)\n\t\t\t\tdbg(\"[FindPH]:#LINE# Text contains this byte! || i=%d\",i)\n\t\t\tend -- text!match(cc) -- }}}\n\t\t\tlocal skip=1\n\t\t\tif i==31 then\n\t\t\t\tskip=96 -- ASCII\n\t\t\tend\n\t\t\ti=i+skip\n\t\tuntil (i==255) -- }}}\n\t\ti=nil\n\t\t--- }}}\n\n\t\tif not(tpr[\"<\"]) or not(tpr[\">\"]) then\n\t\t\terr(\"Impossible to find at least two unused byte codes in this HTML-code. We need it to escape bracket-contained placeholders inside tags.\")\n\t\t\terr(\"Consider enabling 'keep_danger_placeholders' option (to silence this error, if parser wasn't failed with current HTML-code) or manually replace few random bytes, to free up the codes.\")\n\t\telse\n\t\t\tdbg(\"[FindPH]:#LINE# Found! || '<'=%d, '>'=%d\",tpr[\"<\"]:byte(),tpr[\">\"]:byte())\n\t\tend\n\n--\tdbg(\"tpr[>] || tpr[] || #busy%d\")\n\n\t\t-- g {{{\n\t\tlocal function g(id,...)\n\t\t\tlocal arg={...}\n\t\t\tlocal orig=arg[id]\n\t\t\targ[id]=arg[id]:gsub(\"(.)\",tpr)\n\t\t\tif arg[id] ~= orig then\n\t\t\t\ttpl=true\n\t\t\t\tdbg(\"[g]:#LINE# orig: %s\", str(orig))\n\t\t\t\tdbg(\"[g]:#LINE# replaced: %s\",str(arg[id]))\n\t\t\tend\n\t\t\tdbg(\"[g]:#LINE# called, id: %s, arg[id]: %s, args { \"..((\"{%s}, \"):rep(#arg):gsub(\", $\",\"\"))..\" }\",id,arg[id],...)","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/crates/vfox/lua/htmlparser.lua#L70-L106","documentation":"vfox's embedded htmlparser.lua scans bytes 0–255 to find two unused byte codes it can substitute for '<' and '>' while escaping placeholders. If either '<' or '>' has no free replacement code in the parsed HTML, it emits this fatal error: there are no spare byte codes left to perform the escaping.","triggerScenarios":"Parsing HTML content so dense with byte values that both '<' and '>' placeholder mappings cannot find unused codes; occurs inside `FindPH` after the 0..255 scan loop when `tpr[\"<\"]` or `tpr[\">\"]` is nil.","commonSituations":"vfox plugin hooks feeding binary-ish or highly encoded content to the Lua HTML parser; pages with nearly all byte values present; plugins using htmlparser on non-HTML payloads.","solutions":["Enable the 'keep_danger_placeholders' option to silence the error when the parser still succeeds with the current HTML.","Manually replace a few random bytes in the input to free up unused byte codes.","Sanitize/normalize the input before parsing (strip non-text bytes).","Fix the plugin to use a different parsing approach for such payloads."],"exampleFix":"// before\nlocal root = htmlparser.parse(html)\n-- errors: no unused byte codes\n// after\n-- before parsing, free byte codes by replacing exotic bytes\nhtml = html:gsub(\"[\\128-\\255]\", \"\")\nlocal root = htmlparser.parse(html)","handlingStrategy":"validation","validationCode":"-- Lua: ensure input is text-like before parsing\nassert(type(html) == \"string\" and #html > 0, \"non-HTML payload\")","typeGuard":"local function is_html_like(s) return type(s) == \"string\" and s:find(\"<\") ~= nil end","tryCatchPattern":null,"preventionTips":["Enable 'keep_danger_placeholders' when parsing arbitrary HTML.","Strip exotic/control bytes before handing data to htmlparser.","Ensure plugins parse actual HTML, not binary or encoded payloads."],"tags":["lua","vfox","htmlparser","plugin"],"backgroundTag":"internal-invariant-violation","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}