Escape a value for use inside a single GitHub-flavoured Markdown table cell.
MCP error/notes text and serialised queries can include |, raw newlines, and backticks โ all of which corrupt the table layout. We collapse whitespace and escape pipes so each diagnostic row remains a single, parseable row.
Escape ordering matters: backslashes are doubled first so that any subsequent \| insertion remains an unambiguous escaped pipe (an input like foo\ followed by |bar must not be misread as a literal pipe preceded by an escaped backslash). This is the canonical fix flagged by CodeQL js/incomplete-sanitization.
Escape a value for use inside a single GitHub-flavoured Markdown table cell.
MCP error/notes text and serialised queries can include
|, raw newlines, and backticks โ all of which corrupt the table layout. We collapse whitespace and escape pipes so each diagnostic row remains a single, parseable row.Escape ordering matters: backslashes are doubled first so that any subsequent
\|insertion remains an unambiguous escaped pipe (an input likefoo\followed by|barmust not be misread as a literal pipe preceded by an escaped backslash). This is the canonical fix flagged by CodeQLjs/incomplete-sanitization.