Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csp
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
csp
Merge requests
!16
Add style-src 'unsafe-inline' to support CKEditor5
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add style-src 'unsafe-inline' to support CKEditor5
issue/csp-3386187:3386187-ckeditor5-style-src-unsafe-inline
into
8.x-1.x
Overview
0
Commits
3
Pipelines
2
Changes
1
Merged
Chris Snyder
requested to merge
issue/csp-3386187:3386187-ckeditor5-style-src-unsafe-inline
into
8.x-1.x
1 year ago
Overview
0
Commits
3
Pipelines
2
Changes
1
Expand
Closes
#3386187
0
0
Merge request reports
Compare
8.x-1.x
version 3
f6e73e38
1 year ago
version 2
612c7d8b
1 year ago
version 1
00b45b19
1 year ago
8.x-1.x (base)
and
latest version
latest version
f6e73e38
3 commits,
1 year ago
version 3
f6e73e38
3 commits,
1 year ago
version 2
612c7d8b
2 commits,
1 year ago
version 1
00b45b19
1 commit,
1 year ago
1 file
+
26
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/EventSubscriber/CoreCspSubscriber.php
+
26
−
6
Options
@@ -82,12 +82,29 @@ class CoreCspSubscriber implements EventSubscriberInterface {
$policy
->
fallbackAwareAppendIfEnabled
(
'style-src-elem'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
}
// Quickedit loads ckeditor after an AJAX request, so alter needs to be
// applied to calling page.
$quickedit
=
in_array
(
'quickedit/quickedit'
,
$libraries
)
&&
$this
->
moduleHandler
->
moduleExists
(
'ckeditor'
);
// Libraries that load an editor after an AJAX request need their
// exceptions applied to the calling page.
$ajaxEditorLoader
=
(
in_array
(
'layout_builder/drupal.layout_builder'
,
$libraries
)
||
in_array
(
'quickedit/quickedit'
,
$libraries
)
);
// CKEditor requires script attribute on interface buttons.
if
(
in_array
(
'core/ckeditor'
,
$libraries
)
||
$quickedit
)
{
// CKEditor5 requires inline styles for interface.
// @see https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/csp.html
if
(
in_array
(
'core/ckeditor5'
,
$libraries
)
||
(
$ajaxEditorLoader
&&
$this
->
moduleHandler
->
moduleExists
(
'ckeditor5'
))
)
{
$policy
->
fallbackAwareAppendIfEnabled
(
'style-src'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
$policy
->
fallbackAwareAppendIfEnabled
(
'style-src-attr'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
$policy
->
fallbackAwareAppendIfEnabled
(
'style-src-elem'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
}
// CKEditor4 requires script attribute on interface buttons.
if
(
in_array
(
'core/ckeditor'
,
$libraries
)
||
(
$ajaxEditorLoader
&&
$this
->
moduleHandler
->
moduleExists
(
'ckeditor'
))
)
{
$policy
->
fallbackAwareAppendIfEnabled
(
'script-src-elem'
,
[]);
$policy
->
fallbackAwareAppendIfEnabled
(
'script-src'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
$policy
->
fallbackAwareAppendIfEnabled
(
'script-src-attr'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
@@ -95,7 +112,10 @@ class CoreCspSubscriber implements EventSubscriberInterface {
// Inline style element is added by ckeditor.off-canvas-css-reset.js.
// @see https://www.drupal.org/project/drupal/issues/2952390
if
(
in_array
(
'ckeditor/drupal.ckeditor'
,
$libraries
)
||
$quickedit
)
{
if
(
in_array
(
'ckeditor/drupal.ckeditor'
,
$libraries
)
||
(
$ajaxEditorLoader
&&
$this
->
moduleHandler
->
moduleExists
(
'ckeditor'
))
)
{
$policy
->
fallbackAwareAppendIfEnabled
(
'style-src'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
$policy
->
fallbackAwareAppendIfEnabled
(
'style-src-attr'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
$policy
->
fallbackAwareAppendIfEnabled
(
'style-src-elem'
,
[
Csp
::
POLICY_UNSAFE_INLINE
]);
Loading