Skip to content

Commit 4d16950

Browse files
simisonmatticbot
authored andcommitted
Forms: strip HTML from styled labels in error summary (#46319)
* Strip HTML from error labels * Remove extra space between label and `:` Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/20270614315 Upstream-Ref: Automattic/jetpack@617746f
1 parent 965b0b7 commit 4d16950

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ This is an alpha version! The changes listed here are not final.
3737
- Forms: Fix dashboard height
3838
- Forms: Fix slider field text labels showing borders in editor when using certain themes like Assembler
3939
- Forms: fix validation accessibility.
40+
- Forms: strip HTML from styled labels in error summary
4041
- Make form buttons take full width on mobile devices
4142

4243
## [6.22.0] - 2025-12-08

dist/modules/form/view.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('@wordpress/interactivity', 'wp-polyfill'), 'version' => 'b9cbd8502afc51c79dcd', 'type' => 'module');
1+
<?php return array('dependencies' => array('@wordpress/interactivity', 'wp-polyfill'), 'version' => 'e5cee83aeee3e05978bd', 'type' => 'module');

dist/modules/form/view.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/modules/form/view.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ const toggleImageOptionInput = ( input, optionElement ) => {
170170
}
171171
};
172172

173+
const stripHtml = html => {
174+
const doc = new DOMParser().parseFromString( html, 'text/html' );
175+
return doc.body.textContent || '';
176+
};
177+
173178
const { state, actions } = store( NAMESPACE, {
174179
state: {
175180
validators: {},
@@ -301,7 +306,7 @@ const { state, actions } = store( NAMESPACE, {
301306
if ( field.error && field.error !== 'yes' ) {
302307
errors.push( {
303308
anchor: '#' + field.id,
304-
label: field.label + ' : ' + getError( field ),
309+
label: stripHtml( field.label ) + ': ' + getError( field ),
305310
id: field.id,
306311
} );
307312
}

0 commit comments

Comments
 (0)