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

  1. Write a patch
  2. Review
  3. 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

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
StatusFileSize
new857 bytes

Attached patch removes the encoding in theaddress_display_format() function so the output is no longer double escaped.

ralphvdhoudt’s picture

Extra patch for correct display on ajax callback

mvwensen’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.