Forms: esc_shortcode_val() writes decimal entities that unesc_attr() never decodes
Maintainers usually reply within 1 day
@enejb is already working on this.
Since Aug 18, 2026.
Assessment
This issue has not been assessed yet.
Description
Summary
Contact_Form::esc_shortcode_val() encodes four characters as decimal HTML entities so they survive the shortcode parser, but Contact_Form_Shortcode::unesc_attr() only decodes the hex forms. Anything that round-trips through the block → shortcode → render path keeps a raw entity in its value.
Detail
Encoding side — projects/packages/forms/src/contact-form/class-contact-form.php (in esc_shortcode_val()):
'[' => '[',
']' => ']',
'\\' => '\',
',' => ',',
Decoding side — projects/packages/forms/src/contact-form/class-contact-form-shortcode.php (in unesc_attr()):
$value = preg_replace( array( '/�*22;/i', '/�*27;/i', '/�*26;/i', '/�*2c;/i' ), array( '"', "'", '&', ',' ), $value );
$value = htmlspecialchars_decode( $value, ENT_QUOTES );
�*2c; is the hex comma. The decimal , that esc_shortcode_val() actually writes matches neither that pattern nor htmlspecialchars_decode(), which doesn't handle numeric entities at all. Same for [, \, ] — no decoder exists for those in any form.
Why nobody has noticed
Every existing consumer of these attributes emits either through wp_kses_post() or into an HTML attribute value, so the browser decodes the leftover entity on the way to the screen.
It only becomes visible when a value is emitted through esc_html() into a text node: the & gets escaped again and the visitor sees the raw code. Field help text (#51122) was the first such consumer — author types Enter your name, then your email., visitor sees Enter your name, then your email.
Current state
#51122 works around it locally in Contact_Form_Field::get_help_text():
return html_entity_decode( trim( $help_text ), ENT_QUOTES );
That was deliberately scoped to the one affected consumer, since widening unesc_attr() changes what every attribute emits and nothing else is affected today. Per review discussion, the underlying asymmetry is worth fixing properly rather than papering over per-consumer.
Suggested fix
Teach unesc_attr() to decode the decimal forms esc_shortcode_val() actually writes (, [ \ ]), then drop the local html_entity_decode() from get_help_text().
Needs a careful pass over existing consumers first — some may be relying on the browser decoding the leftover entity, and decoding earlier could double-decode author content that legitimately contains , as literal text.
Context
Found during review of #51122. See https://github.com/Automattic/jetpack/pull/51122#discussion_r3770245003.
- Dominant language
- PHP
- Stars
- 1.9k
- Forks
- 913
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 809
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Automattic/jetpack
-
Bug Needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Automattic/jetpack#55870 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Automattic/jetpack#55385 · 1 comment ·
Maintainers usually reply within 1 day
-
WAF: jetpack_waf_blocklog is created without the site's charset and collationPossibly taken @jwebbdev claimed this 3 days ago. Open[Plugin] Protect Bug Customer Report
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Automattic/jetpack#55365 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Package] Stats Admin [Type] Bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Automattic/jetpack#54188 ·
Maintainers usually reply within 1 day
-
Bug Needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/jetpack#53467 ·
Maintainers usually reply within 1 day
All issues in Automattic/jetpack
Similar issues
-
follow-up
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Invoice reminders more than a month after the due date, and bill reminders more than a month before it, are not sentPossibly taken @officialasishkumar claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Automattic/blocks-engine#7881 ·
Maintainers usually reply within 1 day
-
[FrameworkBundle] MicroKernelTrait lists BundleAdapter instead of the bundle class in kernel.bundlesPossibly taken A pull request linked to this issue is open or already merged. OpenBug FrameworkBundle Status: Needs Review
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
[Flaky Test] testMonitorCallbackReturnExitsPossibly taken @uintaam claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
valkey-io/valkey-glide-php#515 ·
Maintainers usually reply within 4 days