Commit 10453ab
Allow block attribute strings to terminate in "\" character (WordPress#71291)
Fix an issue in the block editor where attributes that terminate in the \ character are
mis-encoded and cause block attributes to be lost.
This change encodes `\` characters with their Unicode escape sequence `\u005c`
instead of their escaped form `\\`. This makes the replacement of escaped double quotes
`\"` much simpler because the preceding `\` character must be the escape character for the
quote and an escaped character itself.
Escaping of `\"` was originally introduced in WordPress#6619
to address an issue where `wp_kses_stripslashes()` would replace escaped double quotes `\"`
with plain quotes `"` and break JSON syntax (`{"str":"\""}` becomes `{"str":"""}`).
There is a companion ticket for WordPress Core: https://core.trac.wordpress.org/ticket/63917
And an associated PR to apply the same updated JSON encoding:
WordPress/wordpress-develop#9558
See a related ticket about `wp_kses_stripslashes()` and its purpose today:
https://core.trac.wordpress.org/ticket/63881
---
Unlinked contributors: ehti, Alexius08.
Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
Co-authored-by: dmsnell <dmsnell@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: skorasaurus <skorasaurus@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>1 parent 60986cd commit 10453ab
2 files changed
+24
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
284 | 287 | | |
285 | | - | |
| 288 | + | |
286 | 289 | | |
287 | 290 | | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
297 | 299 | | |
298 | 300 | | |
299 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
| |||
0 commit comments