Browser: Chrome 152
OS: macOS
Hi guys! This one has been costing us silent breakage for a while, and I finally isolated it on 2.4.4.
Environment: Bricks 2.4.4, WordPress 7.1.3, through the Abilities API (reproduced with real MCP calls and with wp_get_abilities()[…]->execute()), as a non-administrator holding bricks_full_access and bricks_execute_code.
What happens
Every ability that writes page elements removes all backslashes from the element settings before saving:
| ability | sent | stored |
|---|---|---|
set-page-elements |
_cssCustom: "%root%::after{content:'\2197'}" |
content: '2197' |
set-page-elements |
text: "x\y" |
"xy" |
update-element |
_cssCustom: "#brxe-t00001::after{content:'\2197'}" |
content: '2197' |
batch-update-elements |
text: "m\n" (literal backslash) |
"mn" |
add-element |
text: "p\q" |
"pq" |
create-post (with elements) |
text: "c\d" |
"cd" |
The paths that keep the backslash: create-global-class (.x::after{content:'\2197'} is stored intact) and commit-html-css-page-import, whose generated global class keeps it.
Why it matters
- A CSS icon written as
content:'\2197'shows the literal text “2197” on the frontend instead of
. - Code elements disappear without a trace. The signature is computed on the code as sent, but the stored code has its backslashes removed, so
verify_code_signature()fails and the element renders nothing:
sent: <b>a\d</b> (executeCode: true)
stored: <b>ad</b>
verify_code_signature(stored signature, stored code) -> false
verify_code_signature(stored signature, sent code) -> true
render: <section …></section> (the code element is gone)
Any regex (\d, \s), PHP namespace (\Bricks\…) or escaped string in a Code element triggers this.
Likely cause
It looks like the classic update_post_meta() → wp_unslash() pitfall: the element tree is passed without wp_slash(). Global classes are stored with update_option(), which doesn’t unslash, which would explain why they’re unaffected.
Suggested fix
wp_slash() the element array before update_post_meta() in the shared element save path. If the signature is computed before saving, compute it on the value that’s actually stored.
Workaround for anyone hitting this: in CSS, write the literal character (content:'↗') instead of an escape, and keep backslashes out of Code elements written through abilities.