Skip to content

Commit

Permalink
Merge pull request #14 from inpsyde/mdr-218/escape-noscript-url
Browse files Browse the repository at this point in the history
IFRAME with invalid URL googletagmanager in SRC attribute
  • Loading branch information
Chrico authored Jun 9, 2022
2 parents e59d226 + 969ab57 commit ab04be1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@
},
"suggest": {
"inpsyde/wonolog": "You may want to install Wonolog to enable logging for this package."
},
"config": {
"allow-plugins": {
"inpsyde/composer-assets-compiler": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion src/Renderer/NoscriptTagRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static function (string $url, DataCollectorInterface $data): string {

$iframe = sprintf(
'<iframe src="%s" height="0" width="0" style="%s"></iframe>',
$url,
\esc_url($url),
'display:none;visibility:hidden'
);

Expand Down
6 changes: 6 additions & 0 deletions tests/phpunit/Unit/Renderer/NoscriptTagRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public function testRender(): void
->with($expected_data, $first_url)
->andReturn($expected_url);

Functions\expect('esc_url')
->once()
->with($expected_url)
->andReturn($expected_url);

ob_start();
$testee->render();
$output = ob_get_clean();
Expand Down Expand Up @@ -144,6 +149,7 @@ public function testRenderAtBodyStart(): void
->andReturn([]);

Functions\stubs(['add_query_arg' => '']);
Functions\stubs(['esc_url' => '']);

$testee = new NoscriptTagRenderer($dataLayer);
ob_start();
Expand Down

0 comments on commit ab04be1

Please sign in to comment.