Skip to content

Implement RFC 9111 compliant quoted-string parsing for Cache-Control directives#3986

Merged
gaby merged 2 commits intoupdate-cache-handling-for-authenticationfrom
copilot/sub-pr-3973
Jan 4, 2026
Merged

Implement RFC 9111 compliant quoted-string parsing for Cache-Control directives#3986
gaby merged 2 commits intoupdate-cache-handling-for-authenticationfrom
copilot/sub-pr-3973

Conversation

Copy link
Contributor

Copilot AI commented Jan 4, 2026

Description

The parseCacheControlDirectives function did not handle quoted-string values per RFC 9111 Section 5.2 / RFC 9110 Section 5.6.4. Directives like community="UCI" were parsed with quotes included in the value ("UCI" instead of UCI). While current directives (max-age, s-maxage, etc.) use token values, proper quoted-string support ensures RFC compliance and future-proofs the parser.

Changes introduced

Implementation:

  • Enhanced parseCacheControlDirectives to detect and unquote quoted-string directive values
  • Added unquoteCacheDirective helper that removes surrounding quotes and processes backslash-escapes
  • Fixed key trimming to handle spaces around = delimiter

Testing:

  • Test_parseCacheControlDirectives_QuotedStrings: 10 test cases covering quoted values, mixed directives, escaped characters
  • Test_unquoteCacheDirective: 9 test cases for unquoting logic including edge cases

Examples:

// Before: quotes included in parsed value
parseCacheControlDirectives([]byte(`community="UCI"`), func(key, value []byte) {
    // value = []byte(`"UCI"`)  // incorrect
})

// After: quotes properly removed
parseCacheControlDirectives([]byte(`community="UCI"`), func(key, value []byte) {
    // value = []byte(`UCI`)  // correct
})

// Escaped characters handled correctly
parseCacheControlDirectives([]byte(`custom="value with \"quotes\""`), func(key, value []byte) {
    // value = []byte(`value with "quotes"`)
})

// Token values (existing behavior) unchanged
parseCacheControlDirectives([]byte(`max-age=3600`), func(key, value []byte) {
    // value = []byte(`3600`)  // works as before
})
  • Documentation Update: N/A - internal parser function
  • Changelog/What's New: RFC 9111 compliant quoted-string parsing for Cache-Control
  • API Longevity: Maintains full backward compatibility; all existing tests pass
  • Examples: See code examples above

Type of change

  • Code consistency (non-breaking change which improves code reliability and robustness)

Checklist

  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Aimed for optimal performance with minimal allocations in the new code.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

…directives

Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.96%. Comparing base (1e57098) to head (14cb87e).
⚠️ Report is 3 commits behind head on update-cache-handling-for-authentication.

Additional details and impacted files
@@                             Coverage Diff                              @@
##           update-cache-handling-for-authentication    #3986      +/-   ##
============================================================================
+ Coverage                                     90.87%   90.96%   +0.09%     
============================================================================
  Files                                           119      119              
  Lines                                         10758    10782      +24     
============================================================================
+ Hits                                           9776     9808      +32     
+ Misses                                          623      617       -6     
+ Partials                                        359      357       -2     
Flag Coverage Δ
unittests 90.96% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI changed the title [WIP] Fix cache middleware compliance for quoted-string values Implement RFC 9111 compliant quoted-string parsing for Cache-Control directives Jan 4, 2026
Copilot AI requested a review from gaby January 4, 2026 21:49
@gaby gaby marked this pull request as ready for review January 4, 2026 21:50
@gaby gaby requested a review from a team as a code owner January 4, 2026 21:50
@gaby gaby requested review from ReneWerner87, Copilot, efectn and sixcolors and removed request for a team and Copilot January 4, 2026 21:50
@gaby gaby merged commit 8862fae into update-cache-handling-for-authentication Jan 4, 2026
17 checks passed
@gaby gaby deleted the copilot/sub-pr-3973 branch January 4, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants