Skip to content

Commit a414129

Browse files
yhabteabnilmerg
authored andcommitted
StyleWithNonce: Don't use nonce for cli commands
1 parent 68667fe commit a414129

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Compat/StyleWithNonce.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ipl\Web\Compat;
44

5+
use Icinga\Application\Icinga;
56
use Icinga\Application\Version;
67
use Icinga\Util\Csp;
78
use ipl\Web\Style;
@@ -15,9 +16,10 @@ class StyleWithNonce extends Style
1516
public function getNonce(): ?string
1617
{
1718
if ($this->nonce === null) {
18-
$this->nonce = version_compare(Version::VERSION, '2.12.0', '>=')
19-
? Csp::getStyleNonce() ?? ''
20-
: '';
19+
$this->nonce = '';
20+
if (version_compare(Version::VERSION, '2.12.0', '>=') && Icinga::app()->isWeb()) {
21+
$this->nonce = Csp::getStyleNonce() ?? '';
22+
}
2123
}
2224

2325
return parent::getNonce();

0 commit comments

Comments
 (0)