Skip to content

fix: fix array handling in ContentSecurityPolicy::setDefaultSrc() and add addDefaultSrc() - #10635

Open
gr8man wants to merge 1 commit into
codeigniter4:developfrom
gr8man:fix/csp-set-default-src
Open

gr8man wants to merge 1 commit into
codeigniter4:developfrom
gr8man:fix/csp-set-default-src

Conversation

@gr8man

@gr8man gr8man commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Description
Fixes ContentSecurityPolicy::setDefaultSrc() when passed an array of URIs, which previously resulted in an invalid 'Array' directive. Also adds addDefaultSrc() to allow appending sources to the default-src directive for consistency with other CSP directive methods.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@carson-codeigniter4 carson-codeigniter4 Bot added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 13, 2026

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gr8man
gr8man force-pushed the fix/csp-set-default-src branch from 5f6b810 to 9f759b5 Compare October 18, 2026 22:04
@paulbalandan paulbalandan changed the title fix: make ContentSecurityPolicy::setDefaultSrc() add directives instead of overwriting fix: make ContentSecurityPolicy::setDefaultSrc() add directives instead of overwriting Oct 19, 2026

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@carson-codeigniter4 carson-codeigniter4 Bot added the stale Pull requests with conflicts label Oct 23, 2026
@carson-codeigniter4

This comment has been minimized.

@paulbalandan paulbalandan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title and body still describes the stale behavior. Please update both.

Comment thread system/HTTP/ContentSecurityPolicy.php Outdated
Comment thread user_guide_src/source/changelogs/v4.7.6.rst Outdated
@gr8man gr8man changed the title fix: make ContentSecurityPolicy::setDefaultSrc() add directives instead of overwriting fix: fix array handling in ContentSecurityPolicy::setDefaultSrc() and add addDefaultSrc() Oct 23, 2026
@gr8man
gr8man force-pushed the fix/csp-set-default-src branch from 9f759b5 to 67da259 Compare October 23, 2026 19:22
@carson-codeigniter4 carson-codeigniter4 Bot removed the stale Pull requests with conflicts label Oct 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants