Repository navigation
Conversation
michalsn
left a comment
There was a problem hiding this comment.
Could we keep setDefaultSrc() replacing the current source list and use addDefaultSrc() to append sources? The existing test explicitly verifies replacement, so changing the setter to append would break existing behavior.
… add addDefaultSrc()
5f6b810 to
9f759b5
Compare
ContentSecurityPolicy::setDefaultSrc() add directives instead of overwriting
|
👋 Hi, @gr8man! We detected conflicts in your PR against the base branch 🙊 Ref: Syncing Your Branch |
paulbalandan
left a comment
There was a problem hiding this comment.
The PR title and body still describes the stale behavior. Please update both.
| * @return $this | ||
| */ | ||
| public function setDefaultSrc($uri, ?bool $explicitReporting = null) | ||
| public function addDefaultSrc($uri, ?bool $explicitReporting = null) |
There was a problem hiding this comment.
I'm not sure whether to allow adding a new method in develop, @michalsn ?
There was a problem hiding this comment.
Should we allow it, then this new method must be fully typed, i.e., with parameter types and return type.
There was a problem hiding this comment.
I'm not sure whether to allow adding a new method in
develop, @michalsn ?
In theory, yes - this should go to 4.8. But in this case, fixing the behavior of setDefaultSrc() could force some users to rewrite parts of their apps, when they could simply switch to addDefaultSrc() to preserve the existing behavior.
That was my reasoning behind allowing this change in develop. Some users might actually rely on the current (incorrect) behavior of setDefaultSrc(), so providing an alternative makes the transition easier.
| 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::setDefaultSrc()`` where passing an array of URIs resulted in an invalid ``'Array'`` directive. Added ``ContentSecurityPolicy::addDefaultSrc()`` to allow appending sources to the ``default-src`` directive. |
There was a problem hiding this comment.
This mixes a fix and an add but should be separated. Depends on the resolution whether we'll allow the new method on develop.
Description
Fixed
ContentSecurityPolicy::setDefaultSrc()overwriting existing directives instead of adding to them, and failing when passed an array of URIs. Also addedaddDefaultSrc()for consistency with other CSP directive methods.Checklist: