-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialized code block is only half escaped #9908
Conversation
This should be intentional per work on our element serializer: #5897 |
To be a bit more precise: IIRC the serializer aims to strictly follow the spec
gutenberg/element/serialize.js Lines 238 to 253 in f496200
|
Ah, gotcha. So when a non-admin user saves a code block, it ends up fully escaped because kses does escaping. It doesn't seem to matter when loading the block back... I guess we're ok with that behaviour? If so, we'll need to exclude the code block fixtures from the kses test, because we know they're going to be different. |
Is there a practical impact from the difference here? Considering that the block validation treats them equivalent: wp.blocks.isEquivalentHTML(
'return <Button>Click Me!</Button>;',
'return <Button>Click Me!</Button>;'
);
// true (Exposing |
There's no difference in actual use. Saving a loading a code block as an author works, so the only real impact here is that a test that makes sure that |
Previously: #9875 |
It seems, from the discussion, that this pull request can be safely closed. Correct? |
Yes, seems so! |
Description
While fixing errors related to
kses
stripping out attributes and tags for non-admin users, I found that the seralized HTML fixture for the code block contains characters that should be htmlentities, but aren't "Fixing" the fixture makes the test fail. Unfortunately, kses does the right thing and converts to entities, so the saved version of the block doesn't match the version the serializer produces.This branch should pass, shouldn't it?