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
Commits
f159366a
Commit
f159366a
authored
1 year ago
by
Chris Snyder
Committed by
Geoff Appleby
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3386187
by ChrisSnyder, gapple: CKEditor5 requires style-src 'unsafe-inline'
parent
838d820e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!16
Add style-src 'unsafe-inline' to support CKEditor5
Pipeline
#63010
passed with warnings
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/EventSubscriber/CoreCspSubscriber.php
+26
-6
26 additions, 6 deletions
src/EventSubscriber/CoreCspSubscriber.php
with
26 additions
and
6 deletions
src/EventSubscriber/CoreCspSubscriber.php
+
26
−
6
View file @
f159366a
...
...
@@ -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
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment