You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Backslashes are stripped from postMeta fields on save (storage-sync.php passes an unslashed value to update_post_meta) #200
A field with postMeta storage loses every backslash when the post is saved. The value a\b is stored as ab.
Affected versions. I ran the steps below on 7.7.11 and 7.7.12 and both lose the backslash. I also saw it on 7.7.7. The line is the same in all three.
Steps to reproduce
Register a block with one text field stored in post meta. I put it in a theme folder, blockstudio/note/block.json, with a one line index.php beside it:
Save a post that contains the block with the value a\b. A REST save does it. In the post content the value sits under blockstudio.attributes, like this:
Read the meta: get_post_meta( $post_id, 'note_summary', true ).
Expected.a\b
Actual.ab
Saving again gives the same result. The block attribute in post_content still has the backslash. Only the meta copy loses it.
Other values, same on 7.7.11 and 7.7.12:
Value in the block
Value in the meta
a\b
ab
a\\b (two backslashes)
a\b
q"x\y"z
q"xy"z
abc
abc
So each backslash is removed, or each pair becomes one. Quotes survive.
Cause.Storage_Sync::sync_field_value() calls update_post_meta( $post_id, $key, $value ) with the value exactly as parsed from the block. WordPress expects meta values to be slashed on input, and update_metadata() runs wp_unslash() on the value before it writes. So a value that was never slashed loses its backslashes.
7.7.7: includes/classes/storage-sync.php line 324
7.7.11: includes/classes/storage-sync.php line 320
7.7.12: includes/classes/storage-sync.php line 320
WordPress core: update_metadata() in wp-includes/meta.php calls wp_unslash( $meta_value ) at line 222 (trunk, read 2026-11-04). The docblock says "For historical reasons both the meta key and the meta value are expected to be slashed".
With it, a\b, a\\b and q"x\y"z are all stored exactly as sent, on the first save and on a second save. wp_slash() handles arrays too, so repeater rows should be covered (not run). The update_option() call next to it needs no change (inferred from core, not run).
Other update_post_meta() calls in includes/ may have the same problem. I only checked the one in storage sync.
I searched the open and closed issues and pull requests for "backslash", "slash", "wp_slash" and "unslash". Nothing matches this bug.
Post-meta storage now preserves literal backslashes, quotes, and nested repeater values on initial saves and resaves. Related meta-backed and custom-post-type database writes are protected too.
After upgrading, re-save affected posts whose saved block attributes still contain the original values to refresh their meta copies.
Regression coverage includes actual WordPress save hooks, repeaters, normal and nested editor saves, reloads, and unchanged-field resaves. Full CI and distribution checks passed. Thanks for the detailed reproduction and regression tests.
Activity
Keep backslashes in values synced to post meta
dnnsjsk commentedon Nov 7, 2026
Fixed and released in 7.7.13, included in 12440a6.
Post-meta storage now preserves literal backslashes, quotes, and nested repeater values on initial saves and resaves. Related meta-backed and custom-post-type database writes are protected too.
After upgrading, re-save affected posts whose saved block attributes still contain the original values to refresh their meta copies.
Regression coverage includes actual WordPress save hooks, repeaters, normal and nested editor saves, reloads, and unchanged-field resaves. Full CI and distribution checks passed. Thanks for the detailed reproduction and regression tests.