Repository navigation
Escape TinyMCE inline CSS in WP editor init - #3597
Merged
Merged
Conversation
JanJakes
force-pushed
the
wp-museum-tinymce
branch
6 times, most recently
from
May 4, 2026 15:01
0d5fea3 to
6550941
Compare
Inline TinyMCE content CSS must be escaped before WordPress serializes it through _WP_Editors::_parse_init(), which wraps settings in JavaScript strings without escaping values. Use json_encode() for the normal path, keep a PHP 5.2-compatible fallback for non-UTF-8 CSS bytes, and cover the browser TinyMCE initialization path in the legacy boot suite.
JanJakes
force-pushed
the
wp-museum-tinymce
branch
from
May 4, 2026 15:22
6550941 to
f471477
Compare
JanJakes
marked this pull request as ready for review
May 4, 2026 16:33
bgrgicak
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Escapes the CSS that Playground inlines into TinyMCE
content_stylethrough the sharedinline-tinymce-content-css.phpmu-plugin.The escape path uses PHP's
json_encode()to produce a JavaScript string body, strips the outer quotes because_WP_Editors::_parse_init()adds them itself, and keeps a small PHP 5.2-compatible fallback for unexpected encoder failures.The legacy WordPress boot suite now also checks the real browser new-post phase for classic TinyMCE bootstrap breakage and fails on
tinyMCEPreInit/content_style/truetypeJavaScript errors without waiting for TinyMCE itself to initialize.Why
_WP_Editors::_parse_init()serializes TinyMCE settings by concatenating JavaScript strings without escaping. Playground's inlined editor CSS can contain quotes, backslashes, newlines, and closing script sequences, for example Dashicons CSS withformat("truetype"). Those characters could break the inlinetinyMCEPreInitscript and leave the classic visual editor uninitialized.Validation
npm exec nx -- run playground-wordpress:lintnode --check packages/playground/wordpress/tests/test-legacy-wp-version-boot.mjsWP_ONLY=3.2,3.1,3.3,4.0,5.5,5.0,2.6,2.5,2.3,2.2,2.1,2.0,1.0 npm exec nx -- run playground-wordpress:test-legacy-wp-version-bootNotes
The sampled legacy browser matrix and lint pass.