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


##########
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:
   Fixed in 80d93f46a0. When an element's first token is unknown, its `=value` 
(token or quoted string) is now skipped the same way as for a known directive, 
and if anything is left the element is scanned for no-cache, no-store and 
private. So `x-custom; private, max-age=600` now cooks as private + 
max-age=600. A well-formed `x-custom=private` is still ignored. New unit rows 
cover `stale-while-revalidate=60; private`, `immutable; private`, `x-ext; 
no-store`, `x-custom; private, max-age=600`, `x-ext="a, b"; private` and the 
leading-semicolon `; private`, plus `x-custom=private` and `x-ext; max-age=600` 
as ignored. All six new restrictive rows fail without the fix.
   



-- 
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