Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# Changelog

All notable changes to this project will be documented in this file.

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

## [Unreleased]

### Added

### Changed

### Removed

### Fixed

## [1.0.1] - 2020-01-01

### Fixed

- Fixed issue where the fetch directive was added twice to the CSP header content.

## [1.0.0] - 2024-08-02

[1.0.1]: https://github.com/basecom/magento2-csp-split-header/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/basecom/magento2-csp-split-header/releases/tag/v1.0.0
7 changes: 3 additions & 4 deletions Plugin/Model/Policy/Renderer/CspHeaderSplitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function afterRender(

if ($isHeaderSplittingEnabled) {
$this->registerCspHeaderPlugins($response);
$this->splitUpCspHeaders($response, $policy->getId(), $policyValue);
$this->splitUpCspHeaders($response, $policyValue);
} else {
if ($maxHeaderSize >= $currentHeaderSize) {
$response->setHeader($headerName, $policyValue, true);
Expand Down Expand Up @@ -87,20 +87,19 @@ private function registerCspHeaderPlugins(HttpResponse $response): void
/**
* Make sure that the CSP headers are handled as several headers ("multi-header")
*/
private function splitUpCspHeaders(HttpResponse $response, string $policyId, string $policyValue): void
private function splitUpCspHeaders(HttpResponse $response, string $policyValue): void
{
$headerName = $this->getHeaderName($response);

if (!$headerName) {
return;
}

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

if ($newHeaderSize <= $maxHeaderSize) {
$this->contentHeaders[] = $newHeader;
$this->contentHeaders[] = $policyValue;
} else {
$this->logger->error(
sprintf(
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "basecom/magento2-csp-split-header",
"version": "1.0.0",
"version": "1.0.1",
"description": "N/A",
"type": "magento2-module",
"license": [
Expand Down