Skip to content

Commit 1d90383

Browse files
apply code suggestions
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
1 parent b086066 commit 1d90383

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

tests/system/HTTP/ContentSecurityPolicyTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,9 @@ public function testGenerateNoncesReplacesPlaceholdersInHtml(): void
951951

952952
$this->assertMatchesRegularExpression('/<style nonce="[A-Za-z0-9+\/=]+">/', $result);
953953
$this->assertMatchesRegularExpression('/<script nonce="[A-Za-z0-9+\/=]+">/', $result);
954-
$this->assertStringNotContainsString('{csp-style-nonce}', (string) $result);
955-
$this->assertStringNotContainsString('{csp-script-nonce}', (string) $result);
954+
$this->assertIsString($result);
955+
$this->assertStringNotContainsString('{csp-style-nonce}', $result);
956+
$this->assertStringNotContainsString('{csp-script-nonce}', $result);
956957
}
957958

958959
#[PreserveGlobalState(false)]
@@ -968,6 +969,7 @@ public function testGenerateNoncesEscapesQuotesInJsonResponse(): void
968969
$result = $this->response->getBody();
969970
$parsed = json_decode($result, true);
970971

972+
$this->assertSame(JSON_ERROR_NONE, json_last_error());
971973
$this->assertNotNull($parsed);
972974
$this->assertMatchesRegularExpression('/nonce="[A-Za-z0-9+\/=]+"/', $parsed['html']);
973975
}

user_guide_src/source/changelogs/v4.7.1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Deprecations
3030
Bugs Fixed
3131
**********
3232

33-
- **ContentSecurityPolicy:** Fixed a bug where ``generateNonces()`` corrupted JSON responses by replacing CSP nonce placeholders with unescaped double quotes. The method now automatically JSON-escapes nonce attributes when the response Content-Type is JSON.
33+
- **ContentSecurityPolicy:** Fixed a bug where ``generateNonces()`` produces corrupted JSON responses by replacing CSP nonce placeholders with unescaped double quotes. The method now automatically JSON-escapes nonce attributes when the response Content-Type is JSON.
3434

3535
See the repo's
3636
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

0 commit comments

Comments
 (0)