﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37424	"CacheMiddleware does not correctly handle whitespace between ""max-age"" and the equals sign"	Jacob Walls	Jacob Walls	"Failing test:

{{{#!diff
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index 96385fd084..3f7aec4961 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -2330,6 +2330,9 @@ class CacheUtils(SimpleTestCase):
             (""no-cache,\tmax-age=600"", 600),
             # Whitespace after the value is handled by int() transparently.
             (""max-age=300 "", 300),
+            # Whitespace preceding the =.
+            (""max-age =300"", 300),
+            (""max-age\t=300 "", 300),
         ]
         for header_value, expected in tests:
             with self.subTest(header_value=header_value):
}}}
{{{#!py
AssertionError: None != 300
}}}

I believe we need changes analogous to `patch_cache_control()`, which calls `strip()` in `_to_tuple()`, see `test_patch_cache_control_whitespace_around_equals()`:
{{{#!py
        if len(t) > 1:
            return (t[0].strip().lower(), t[1])
        else:
            return (t[0].lower(), True)
}}}

Not a security issue, same class of public hardening as b461519bf5973d7fc149560d2f99acdba71a437d

Thanks Aaron Chen for the report."	Bug	assigned	Core (Cache system)	6.1	Normal		not-security		Unreviewed	1	0	0	0	1	0
