Opened 70 minutes ago
Last modified 58 minutes ago
#37424 assigned Bug
CacheMiddleware does not correctly handle whitespace between "max-age" and the equals sign
| Reported by: | Jacob Walls | Owned by: | Jacob Walls |
|---|---|---|---|
| Component: | Core (Cache system) | Version: | 6.1 |
| Severity: | Normal | Keywords: | not-security |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
Failing test:
-
tests/cache/tests.py
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 96385fd084..3f7aec4961 100644
a b class CacheUtils(SimpleTestCase): 2330 2330 ("no-cache,\tmax-age=600", 600), 2331 2331 # Whitespace after the value is handled by int() transparently. 2332 2332 ("max-age=300 ", 300), 2333 # Whitespace preceding the =. 2334 ("max-age =300", 300), 2335 ("max-age\t=300 ", 300), 2333 2336 ] 2334 2337 for header_value, expected in tests: 2335 2338 with self.subTest(header_value=header_value):
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():
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.
Note:
See TracTickets
for help on using tickets.
PR