Skip to content

Commit

Permalink
Add nonce attribute to all JavaScript tags in snippet templates autom…
Browse files Browse the repository at this point in the history
…atically
  • Loading branch information
yurabakhtin committed Dec 12, 2023
1 parent 6d882f6 commit b506dc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions controllers/AbstractCustomContainerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use humhub\components\access\StrictAccess;
use humhub\modules\admin\permissions\ManageModules;
use humhub\modules\content\components\ContentContainerController;
use humhub\modules\custom_pages\helpers\Html;
use humhub\modules\custom_pages\models\ContainerPage;
use humhub\modules\custom_pages\models\ContainerSnippet;
use humhub\modules\custom_pages\models\CustomContentContainer;
Expand Down Expand Up @@ -116,8 +117,6 @@ public function renderTemplate($page, $editMode = null)
$canEdit = PagePermission::canEdit();
$editMode = ($editMode || Yii::$app->request->get('editMode')) && $canEdit;

$html = '';

if(!$canEdit && TemplateCache::exists($templateInstance)) {
$html = TemplateCache::get($templateInstance);
} else {
Expand All @@ -126,7 +125,8 @@ public function renderTemplate($page, $editMode = null)
TemplateCache::set($templateInstance, $html);
}
}
return $html;

return Html::applyScriptNonce($html);
}

/**
Expand All @@ -148,4 +148,4 @@ public function isCanEdit() {
return $this->_canEdit;
}

}
}
2 changes: 1 addition & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
Unreleased
-------------------------
- Fix #312: Highlight the top menu entry if the current URL matches the Target Url of a "Link" custom page
- Enh #314: Add nonce attribute to all HTML snippets automatically
- Enh #314: Add nonce attribute to all JavaScript tags in snippet templates and HTML snippets automatically

1.9.5 (November 16, 2023)
-------------------------
Expand Down

0 comments on commit b506dc0

Please sign in to comment.