mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-29 15:44:27 +00:00
Editor: Ensure block attribute serialization in PHP matches the JavaScript equivalent.
The `serializeAttributes()` function in JavaScript uses `JSON.stringify`, which does not encode slashes and unicode characters by default. This resulted in the PHP serialization through `json_encode()` producing different results. This also switches from `json_encode()` to `wp_json_encode()` to prevent failures when any non UTF-8 characters are included. Props kevinfodness, SergeyBiryukov, timothyblynjacobs. Fixes #53936. git-svn-id: https://develop.svn.wordpress.org/trunk@51674 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -47,6 +47,9 @@ class Tests_Blocks_Serialize extends WP_UnitTestCase {
|
||||
|
||||
// Block with attribute values that may conflict with HTML comment.
|
||||
array( '<!-- wp:attributes {"key":"\\u002d\\u002d\\u003c\\u003e\\u0026\\u0022"} /-->' ),
|
||||
|
||||
// Block with attribute values that should not be escaped.
|
||||
array( '<!-- wp:attributes {"key":"€1.00 / 3 for €2.00"} /-->' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user