Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Empty-value handling and mixed reporting modes can silently remove enforced security restrictions.
4 open issues
What changed in this PR
Normalizes Content Security Policy values to address keyword quoting, empty entries, and numeric-key type errors.
Changes:
- Splits configured strings and normalizes header keys.
- Adds regression tests for normalization and sandbox flags.
- Documents the fix in the changelog.
Base branch is unspecified; develop compatibility rules were assumed. Validation used targeted code inspection; automated tests remain for CI.
| File | Description |
|---|---|
| user_guide_src/source/changelogs/v4.7.6.rst | Documents the normalization fix. |
| tests/system/HTTP/ContentSecurityPolicyTest.php | Adds normalization regression tests. |
| system/HTTP/ContentSecurityPolicy.php | Changes option normalization and header generation. |
Review effort: Balanced
74c4afa to
6e01df9
Compare
This comment has been minimized.
This comment has been minimized.
6e01df9 to
607c93d
Compare
ContentSecurityPolicy::addOption()
a37fe7c to
3fbbfb9
Compare
paulbalandan
left a comment
There was a problem hiding this comment.
Please rebase to resolve conflicts
| is used instead. Values that cannot be converted to a string, such as objects | ||
| not implementing ``Stringable``, now throw a ``FormatException`` instead of a | ||
| fatal ``Error``. | ||
| - **HTTP:** Fixed a bug in ``ContentSecurityPolicy::addOption()`` where converting string directive values to array keys resulted in invalid entries for empty strings, unquoted values for space-separated lists, and ``TypeError`` for numeric strings. |
There was a problem hiding this comment.
Nit: instead of describing the protected method's change, maybe describe more the user-facing change? Something like:
HTTP: Fixed a bug in ContentSecurityPolicy where a numeric source such as '0' threw a TypeError, and a space-separated directive string in Config\ContentSecurityPolicy was emitted as one unquoted source.
…tion() - Normalize space-separated and empty strings into array options via stringToOptions() - Cast numeric string array keys back to string to prevent TypeError under strict types - Preserve empty source lists as deny-all directives across all directives - Retain empty markers when other options move between reporting modes - Add comprehensive regression tests for config and runtime directives
3fbbfb9 to
66d0006
Compare

Description
Fixed
ContentSecurityPolicy::addOption()andaddToHeader()converting string values directly into array keys, which created invalid entries for empty strings, prevented keyword quoting for space-separated lists, and caused a fatalTypeErrorin PHP 8 strict mode when numeric strings were converted to integer array keys.Checklist: