Copilot commented on code in PR #13913:
URL: https://github.com/apache/trafficserver/pull/13913#discussion_r4457307543


##########
src/proxy/hdrs/MIME.cc:
##########
@@ -3996,19 +4028,21 @@ MIMEHdrImpl::recompute_cooked_stuff(MIMEField 
*changing_field_or_null, const std
             // This can happen, for instance, if the host uses semicolons
             // instead of commas as separators which is against RFC 7234 (see
             // issue #12029). Regardless of the cause, this means we need to
-            // ignore the directive and clear any mask bits we set from it.
+            // ignore the directive and clear any mask bits we set from it,
+            // except for the restrictive directives handled below.
             while (c < e && ParseRules::is_ws(*c)) {
               ++c;
             }
             if (c < e) {
               // There's non-whitespace content that wasn't parsed. This means
               // that we cannot really understand what this directive is.
-              // Per RFC 7234 Section 5.2: "A cache MUST ignore unrecognized 
cache
-              // directives."
-              if (csv_value_mask != 0) {
-                // Reverse the mask that we set above.
-                m_cooked_stuff.m_cache_control.m_mask &= ~csv_value_mask;
-              }
+              // Per RFC 9111 Section 5.2.3: "A cache MUST ignore unrecognized
+              // cache directives." A no-cache, no-store or private named
+              // anywhere in the element is kept, though: dropping it could
+              // expose a response that the origin meant to protect, such as
+              // with "private; max-age=600" or "max-age=600; private".
+              m_cooked_stuff.m_cache_control.m_mask &= ~csv_value_mask;
+              m_cooked_stuff.m_cache_control.m_mask |= 
restrictive_cc_directives_in(s, e);

Review Comment:
   Recovery runs only when `hdrtoken_tokenize` recognizes the first token, so 
`Cache-Control: x-custom; private, max-age=600` still drops `private` and 
leaves the response eligible for shared caching. Validate malformed elements 
and recover their restrictions even when the initial token is unknown, while 
leaving valid extension arguments such as `x-custom=private` ignored. Add 
regression cases for unknown-token and leading-semicolon prefixes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to