Skip to content

Commit 3edae74

Browse files
authored
fix: build content header correctly (#1)
1 parent 51eb0e5 commit 3edae74

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)
56
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
67

78
## [Unreleased]
9+
810
### Added
11+
912
### Changed
13+
1014
### Removed
15+
1116
### Fixed
17+
18+
## [1.0.1] - 2020-01-01
19+
20+
### Fixed
21+
22+
- Fixed issue where the fetch directive was added twice to the CSP header content.
23+
24+
## [1.0.0] - 2024-08-02
25+
26+
[1.0.1]: https://github.com/basecom/magento2-csp-split-header/compare/v1.0.0...v1.0.1
27+
[1.0.0]: https://github.com/basecom/magento2-csp-split-header/releases/tag/v1.0.0

Plugin/Model/Policy/Renderer/CspHeaderSplitter.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function afterRender(
5353

5454
if ($isHeaderSplittingEnabled) {
5555
$this->registerCspHeaderPlugins($response);
56-
$this->splitUpCspHeaders($response, $policy->getId(), $policyValue);
56+
$this->splitUpCspHeaders($response, $policyValue);
5757
} else {
5858
if ($maxHeaderSize >= $currentHeaderSize) {
5959
$response->setHeader($headerName, $policyValue, true);
@@ -87,20 +87,19 @@ private function registerCspHeaderPlugins(HttpResponse $response): void
8787
/**
8888
* Make sure that the CSP headers are handled as several headers ("multi-header")
8989
*/
90-
private function splitUpCspHeaders(HttpResponse $response, string $policyId, string $policyValue): void
90+
private function splitUpCspHeaders(HttpResponse $response, string $policyValue): void
9191
{
9292
$headerName = $this->getHeaderName($response);
9393

9494
if (!$headerName) {
9595
return;
9696
}
9797

98-
$newHeader = $policyId.' '.$policyValue.';';
9998
$maxHeaderSize = $this->config->getMaxHeaderSize();
10099
$newHeaderSize = strlen($policyValue);
101100

102101
if ($newHeaderSize <= $maxHeaderSize) {
103-
$this->contentHeaders[] = $newHeader;
102+
$this->contentHeaders[] = $policyValue;
104103
} else {
105104
$this->logger->error(
106105
sprintf(

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "basecom/magento2-csp-split-header",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "N/A",
55
"type": "magento2-module",
66
"license": [

0 commit comments

Comments
 (0)