-
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
Rich Text: also strip object replacement character when removing padding #34851
Conversation
Size Change: -279 B (0%) Total Size: 1.06 MB
ℹ️ View Unchanged
|
febf219
to
43d7c2c
Compare
Probably I shouldn't get too involved here because I'm sensitive to this stuff and ignorant about what's going on. Still, why are we dealing with |
@dmsnell The TL;DR is that it's used internally in rich text. We should ignore any user provided usages to avoid errors being thrown during tree creation. |
That makes sense. This isn't really about padding then so much as it is about removing reserved characters…? I guess that's what causes the crash? You enter a |
💯 yes that's the gist of it. |
Interesting that users are pasting this character. Where are they getting this from? Maybe it's leaking somewhere when copying text? It's interesting that this only starts happening now, we've been using this character internally for a long time. |
expect( removeReservedCharacters( `${ ZWNBSP }` ) ).toEqual( '' ); | ||
expect( | ||
removeReservedCharacters( | ||
`${ OBJECT_REPLACEMENT_CHARACTER }c${ OBJECT_REPLACEMENT_CHARACTER }at${ OBJECT_REPLACEMENT_CHARACTER }` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 🐈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and verified this no longer crashes the editor.
Thanks for the reviews @ellatrix @getdave @dmsnell @mkaz ! I'll go ahead and merge this once tests are green.
I asked folks and some reports are from users who are copying text from MS Word. It's definitely something to keep an eye on though! |
Fixes #34602. Rich text instances should ignore the object replacement character U+FFFC, since this is used internally by the package.
Changes here strip this special character when we remove other whitespace characters like
u+feff
,Testing Instructions
This post title crashes Gutenberg 
Verify that no JS errors are thrown