Skip to content

ContentSecurityPolicy::setReportURI() shoud accept null values #9091

Closed
@allpassos

Description

@allpassos

PHP Version

8.1

CodeIgniter4 Version

4.5.3

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

MySQL 8.0.30

What happened?

Trying to set with runntime $reportURI property from app/Config/ContentSecurityPolicy.php to null in BaseController, throws an exception:

message: CodeIgniter\HTTP\ContentSecurityPolicy::setReportURI(): Argument #1 ($uri) must be of type string, null given, called in C:\laragon\www\...\app\Controllers\BaseController.php on line 70
file: C:\laragon\www\newawm\vendor\codeigniter4\framework\system\HTTP\ContentSecurityPolicy.php  on line 599

This shoud happen because $reportURI from app/Config/ContentSecurityPolicy.php accept ?string. The sabe the core config file. However the propertie inside system\HTTP\ContentSecurityPolicy.php just accept strings.

__

Steps to Reproduce

  1. Inside BaseController -> public function initController add the following code:
if(!empty($this->session->get('system'))) { ...
   // get the CSP instance
   $csp = $this->response->getCSP();
   $csp->setReportURI(null);

Expected Output

The CSP (from Codeigniter\HTTP\ContentSecurityPolicy) object inside the response object (Codeigniter\HTTP\Response) setted as null

Anything else?

$csp->setReportURI('null') or $csp->setReportURI('') do the job. So I can handle it in the model

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions