-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Patterns: use existing download function for JSON downloads to fix non-ASCII encoding #55912
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
Conversation
Gutenberg's reusable blocks code has an existing download function that we can use for JSON. This commit removes the downloadjs dependency and copies over the reusable blocks download function.
|
Size Change: +90 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
glendaviesnz
left a comment
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 well for me. It could potentially be better placed in the page-patterns/utils folder or in the @wordpress/patterns package, but given this is the only use of it so far it probably makes sense to keep it here - can be easily moved later if the export option is added in other places.
|
This dependency could just as well be replaced in |
I saw that in there and hesitated as it's used to download But yes, it's worth testing to see if we can remove altogether. |
|
PR to remove |
|
Ah yes, very possibly. The issue is on the 6.4 editor tasks list I see. I've added the label and will ping in the WP Slack channel. Thanks! |
|
6.4.2 point release PR going on here: |
|
I just cherry-picked this PR to the 6.4-next-point-release branch to get it included in the next release: 6f2a988 |
…n-ASCII encoding (#55912) * downloadjs has a bug where it cannot decode non-ASCII characters. Gutenberg's reusable blocks code has an existing download function that we can use for JSON. This commit removes the downloadjs dependency and copies over the reusable blocks download function. * Added comment to explain duplicate * Remove IE11-specific code.
…n-ASCII encoding (#55912) * downloadjs has a bug where it cannot decode non-ASCII characters. Gutenberg's reusable blocks code has an existing download function that we can use for JSON. This commit removes the downloadjs dependency and copies over the reusable blocks download function. * Added comment to explain duplicate * Remove IE11-specific code.
What?
Maybe resolves #55746
Patterns that contain non-ASCII characters are corrupted on download.
Why?
The downloadjs module patterns is using seems to have a non-resolved bug where it cannot properly encode non-ASCII characters.
How?
Use the same, internal function as the reusable blocks.
We're downloading only JSON so we don't need any special functionality I gather?
Testing Instructions
Create a new pattern with the following content:
Save the pattern.
Export the pattern.
Re-import the pattern.
Import should work!
Before
{ "__file": "wp_block", "title": "Non ASCII", "content": "<!-- wp:paragraph -->\n<p>This is a pattern containing non-ASCII characters �W�H> ~=[]()%+{}@;�#!$_&- �� ;���� ����� We hop� you find it inform@tiv� Thank You!</p>\n<!-- /wp:paragraph -->", "syncStatus": "" }After
{ "__file": "wp_block", "title": "Non ASCII", "content": "<!-- wp:paragraph -->\n<p>This is a pattern containing non-ASCII characters 文字出版社 ~=[]()%+{}@;’#!$_&- éè ;∞¥₤€ ワードプレス We hopè you find it inform@tiv€ Thank You!</p>\n<!-- /wp:paragraph -->", "syncStatus": "" }