fix(http/unstable): align Cache-Control with RFC 9111 quoted-string and field-name rules#7116
fix(http/unstable): align Cache-Control with RFC 9111 quoted-string and field-name rules#7116tomas-zijdemans wants to merge 4 commits intodenoland:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7116 +/- ##
=======================================
Coverage 94.61% 94.61%
=======================================
Files 634 634
Lines 51801 51816 +15
Branches 9329 9333 +4
=======================================
+ Hits 49011 49026 +15
Misses 2216 2216
Partials 574 574 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bartlomieju
left a comment
There was a problem hiding this comment.
Thanks for the RFC compliance fix — the unquoteArgument helper and tchar validation are correct and well-tested.
A couple of nits:
Missing PR description — the body is empty. A brief note on what was wrong (e.g. quoted-string numeric args rejected, only \" unescaped instead of all quoted-pairs, no field-name validation on output) would help reviewers and show up in the changelog.
splitDirectives has the same quoted-pair blindspot — it toggles inQuotes on every " including those inside a \" quoted-pair. Since this PR is specifically improving quoted-pair handling in unquoteArgument and parseFieldNames, it would be consistent to also handle backslash escapes in splitDirectives (or at least leave a // TODO noting the limitation). In practice field names are tokens so they can't contain ", but it's an odd gap given the rest of the work here.
|
Thanks,
|
Tightens
parseCacheControl/formatCacheControlagainst RFC 9111 §5.2 + RFC 9110 §5.6.4 / §5.6.2:max-age,s-maxage,min-fresh,max-stale,stale-while-revalidate, andstale-if-errornow accept both token and quoted-string production (e.g.max-age="60"). Previously the quotes were treated as part of the value and rejected.\". RFC 9110 §5.6.4 allows\Xfor anyXinVCHAR / obs-text / SP / HTAB. The old parser only stripped\\"; quoted-pairs like\\\\(literal backslash) were left intact. A sharedunquoteArgumenthelper now performs the full unescape and is reused by both numeric and field-name argument parsing.formatCacheControlnow rejects any entry ofnoCache/privatethat isn't a valid HTTP token (RFC 9110 §5.6.2tchar), throwingTypeErrorinstead of emitting a malformedno-cache="has space"style header that downstream caches would reject or misinterpret.