-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Block Supports: Add missing UTF-8 conversion #24447
Conversation
@swissspidy: I'd love your eyes on this, if you can spare some time |
The fix for 8.7 needs to be applied to (Code was moved and files renamed by #24351) |
Size Change: +381 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
OK, so this is not affecting WP 5.5 (feel free to double-check), which makes sense considering that the functionality in question (Global Styles-related block support) was intentionally merged after code freeze. I'll update the metadata accordingly. |
I've also tested and confirmed that this does not appear to affect WordPRess 5.5. |
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.
I am not an expert in encodings nor DOM manipulations via PHP.
I have confirmed this bug is present in Gutenberg 8.7.
I have tested and confirms that this fixes it in my testing:
I've created a post with a Cover block containing the text こんにちは世界
.
Without the patch:
With the patch applied (the block is un-edited):
This may be worth an 8.7.1 release.
😕 Seems like the DOM operation might remove the empty Cover div? 🤔 |
Seems to pass locally. I'll re-run the test. |
Passing now 😌 We should add some test coverage for this though 🤔 |
A simple unit test for |
I'll try writing a quick unit test for this. |
Added a unit test. I also discovered that I needed to add a line to convert HTML entities back to UTF-8 (after |
FWIW, cherry-picked the unit test commit on top of |
* Block Supports: Add missing UTF-8 conversion * Re-encode back to UTF-8 * Add unit test
Sets the charset of the html passed into DomDocument to utf-8. Replaces the mb_convert_encoding call replacing utf-8 with html entities before handing off to DomDocument. This avoids the need to later convert back to utf-8 from html entities afterward. This secondary mb_convert_encoding call was converting not only the utf-8 we converted earlier but also entity encoding html stored inside data-* or other attributes of html elements. Fixes Automattic/wp-calypso#44897 Maintains the fix for WordPress#24445 (WordPress#24447)
Description
Fixes #24445.
This should probably be backported to 8.7 (and potentially further back if needed).
How has this been tested?
See #24445 for instructions on how to reproduce the issue. Verify that this PR fixes it.
Types of changes
Bug fix.
Checklist:
props @akirk @sirreal @simison for finding the fix