Problem/Motivation
The address components are double encoded in the submission display and rendered value. This results in html entities displayed as #039; for example.
Component declaration:
/**
* Implements _webform_display_component().
*/
function _webform_display_address($component, $value, $format = 'html') {
return array(
'#title' => $component['name'],
'#weight' => $component['weight'],
'#theme' => 'webform_display_address',
'#theme_wrappers' => $format == 'html' ? array('webform_element') : array('webform_element_text'),
'#post_render' => array('webform_element_wrapper'),
'#component' => $component,
'#format' => $format,
'#value' => isset($value) ? address_display_format($value) : '',
);
}
First time encoded:
function address_display_format(array $value) {
$street = $value['street_name'] . ' ' . $value['house_number'];
if (isset($value['house_letter'])) {
$street .= $value['house_letter'];
}
if (isset($value['house_number_addition'])) {
$street .= ' ' . $value['house_number_addition'];
}
return check_plain($street . ', ' . $value['postal_code'] . ' ' . $value['city']);
}
Second time encoded:
function theme_webform_display_address(array $variables) {
$element = $variables['element'];
$value = $element['#format'] == 'html' ? check_plain($element['#value']) : $element['#value'];
return $value !== '' ? $value : ' ';
}
Proposed resolution
Remove the double encoding in theaddress_display_format() function.
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
Html entities in address components are not longer displayed as escaped entities to end users.
API changes
None.
Data model changes
None.
Comments
Comment #2
idebr commentedAttached patch removes the encoding in the
address_display_format()function so the output is no longer double escaped.Comment #3
ralphvdhoudt commentedExtra patch for correct display on ajax callback
Comment #5
mvwensen commented