Problem/Motivation
Recently, https://www.drupal.org/node/3245019 seems to have tightened up the allowable HTML markup within Webform elements' titles. Unfortunately, it seems that the the new restrictions has removed the ability for titles to span multiple lines (via <br> for example).

Steps to reproduce
- Install Webform 6.0.x
- Configure an element with a
<br> in the title that makes it span multiple lines.
- Upgrade to Webform 6.1.x
- Notice that the title is no longer multi-line
Proposed resolution
Can we allow <br> tags in the '#title'?
@@ -784,6 +785,12 @@ class WebformElementBase extends PluginBase implements WebformElementInterface,
$element['#attributes']['data-webform-required-error'] = WebformHtmlHelper::toPlainText($element['#required_error']);
$element['#required_error'] = WebformHtmlHelper::toHtmlMarkup($element['#required_error']);
}
// Convert #title to HTML markup so that it can displayed properly
// in error messages.
if (isset($element['#title'])) {
- $element['#title'] = WebformHtmlHelper::toHtmlMarkup($element['#title'], WebformXss::getHtmlTagList());
+ $element['#title'] = WebformHtmlHelper::toHtmlMarkup($element['#title'], WebformXss::getHtmlTagList() + ['br']);
}
}
or perhaps add <br> to the list of allowed tags in the WebformXss utility class?
Is there a security angle that I'm not seeing here?
Remaining tasks
TBD
User interface changes
None
API changes
None
Data model changes
None
Thanks so much!
Comments
Comment #2
jrockowitz commentedI think adding support for multiline titles is a good idea.
Comment #5
jrockowitz commentedComment #8
charginghawk commented