Repository navigation
fix: acceptParams truncates quoted values containing a semicolon - #7479
mdalikadar wants to merge 2 commits into
Conversation
|
I haven't reviewed this and don't plan to, but here are some relevant definitions from RFC 9110 (only most important parts, follow the links for full text):
|
| for (var i = fromIndex; i < str.length; i++) { | ||
| var c = str[i]; | ||
|
|
||
| if (c === '"' && str[i - 1] !== '\\') { |
There was a problem hiding this comment.
This checks only the immediately preceding character, so an escaped backslash right before a closing quote reads as escaping that quote instead. Quoted never toggles to false there, so a value swallows every parameter after it.
A finding cannot be judged without the code it is about, and the patch is
already on the page — so this is a slice of it, not a fetch.
- lib/findings/snippet.ts three lines either side of the target, taken from the
parsed hunk. Sliced by array position rather than by
arithmetic on line numbers, so deleted lines — which
carry no new-side number — stay interleaved where they
belong. A multi-line finding marks its whole range,
and a line that is not in the diff returns nothing,
since a file-level finding has no code to show.
- DiffSnippet.tsx the target line is marked with a border, not colour
alone, consistent with the disposition treatment.
Verified against the real patch for expressjs/express#7479: the snippet for the
finding at lib/utils.js:143 lands exactly on `str[i - 1] !== '\\'`, the line the
agent flagged, with context either side and truncation markers.
642 tests, 95.8% coverage. Closes BACKLOG B2.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
res.format()normalizes its keys throughacceptParams()inlib/utils.js, which parses each;-separated parameter by scanning for the next raw;to know where the value ends. That breaks when the value is a quoted string that legitimately contains a;, e.g.:Right now this parses
fooas"aand silently drops the rest (b"), because the parser has no idea it's inside quotes when it hits that semicolon. I ran into this while poking aroundres.format()and figured it was worth fixing properly rather than patching around it.The fix adds a small helper,
indexOfUnquoted(), that walks the string and ignores delimiters found inside a quoted span (also handles an escaped\"so it doesnt end the quote early), and swap it in for the oneindexOf(';')call that needed it. Everything else aboutacceptParamsis untouched — same behavior for plain types, missing=, malformed params, etc.Added two tests in
test/utils.jscovering the quoted-semicolon case and the escaped-quote case. Ran the full suite locally (1263 passing) and lint is clean.