Skip to content

Commit 5df55f4

Browse files
committed
Add missing style-src=unsafe-inline directive for site requests if the Yii debug bar is enabled. Bump to 1.3.1
1 parent 8bba3c0 commit 5df55f4

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ToolMate Changelog
22

3+
## 1.3.1 - 2022-05-12
4+
### Fixed
5+
- Fixed an issue where ToolMate failed to include the `'unsafe-inline'` policy resource for the `style-src` CSP directive to `unsafe-inline`, for site requests where the Yii debug toolbar is enabled
6+
37
## 1.3.0.3 - 2022-04-28
48
### Fixed
59
- Fixed issue in Settings introduced in the Craft 4 refactoring.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vaersaagod/toolmate",
33
"description": "Is that a tool in your pocket, or are you just happy to see me, mate?",
44
"type": "craft-plugin",
5-
"version": "1.3.0.3",
5+
"version": "1.3.1",
66
"keywords": [
77
"craft",
88
"cms",

src/services/CspService.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ public function setHeader(): void
5353
// Get directives
5454
$directivesConfig = $config->getDirectives();
5555

56-
// If this is a CP request, make sure some needed policies are included
5756
if (Craft::$app->getRequest()->getIsSiteRequest()) {
58-
// If the Yii debug toolbar is visible on the front end, we unfortunately need to set the `unsafe-inline` policy for the script-src directive
57+
// If the Yii debug toolbar is visible on the front end, we unfortunately need to set the `unsafe-inline` policy for the script-src and style-src directive
5958
$currentUser = Craft::$app->getUser()->getIdentity();
6059
if ($currentUser instanceof User && $currentUser->getPreference('enableDebugToolbarForSite')) {
6160
$directivesConfig->scriptSrc[] = "'unsafe-inline' 'unsafe-eval'";
61+
$directivesConfig->styleSrc[] = "'unsafe-inline'";
6262
}
6363
} elseif (Craft::$app->getRequest()->getIsCpRequest()) {
64+
// If this is a CP request, make sure some needed policies are included
6465
$directivesConfig->frameAncestors[] = "'self'";
6566
$directivesConfig->scriptSrc[] = "'unsafe-inline' 'unsafe-eval'";
67+
$directivesConfig->styleSrc[] = "'unsafe-inline'";
6668
}
6769

6870
// Convert directive names to kebab-case, remove duplicates, etc

0 commit comments

Comments
 (0)