Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The updated QUOTED_STRING still permits escaped carriage returns (via \\.), so line breaks can still slip through in quoted values despite the new rejection intent/tests.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the quoted-string parsing used by HTTP::Accept::MediaTypes to avoid QUOTED_STRING over-matching (particularly around escaped backslashes), and adds regression tests to validate correct Accept header parsing behavior.
Changes:
- Replace the
QUOTED_STRINGregex used for parsing quoted parameter values. - Add a regression test for a quoted value ending in an escaped backslash.
- Add tests asserting line breaks inside quoted values are rejected.
File summaries
| File | Description |
|---|---|
| test/http/media_types.rb | Adds regression tests for quoted-string edge cases in Accept header parameter parsing. |
| lib/http/accept/quoted_string.rb | Updates the QUOTED_STRING regex used by the Accept header parser. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # According to https://tools.ietf.org/html/rfc7231#appendix-C | ||
| TOKEN = /[!#$%&'*+\-.^_`|~0-9A-Z]+/i | ||
| QUOTED_STRING = /"(?:.(?!(?<!\\)"))*.?"/ | ||
| QUOTED_STRING = /"(?:[^"\\\r\n]|\\.)*"/ |
| [ | ||
| "foo/bar;x=\"line\rbreak\"", | ||
| "foo/bar;x=\"line\nbreak\"", | ||
| ].each do |text| |
|
The proposed fix was released in v2.2.2 but it looks like we might need another refinement to the pattern? |
bugfix: a minor improvement to a header parsing