When viewing a list of nodes in a select list on a node reference field, if their titles contain special characters they are displayed as html entity numbers rather than the character.

Eg: A title of 'Women's team' appears as 'Women's team' in the select list.

( Similar to #1357556: Convert &amp in nodereference titles to Ampersand ? )

Comments

sahuni’s picture

Also for ampersand in select box.
For example if title is "Cas d'école", select box shows : Casd'cole

dubs’s picture

Yes, I also see this problem and and for me it occurs if References are used as Views Exposed Filters.

_paul_meta’s picture

Yep same issue here. When i create a node, if one of the fields is a select field of node references, any special characters in the node title display as html entity numbers. using 7.20.

alexverb’s picture

Are you by any chance using hierachical select's hs_taxonomy? I've got the same thing happening when using it's formatter to display the links in lineage.

xpersonas’s picture

Subscribe

alexverb’s picture

This code in node_reference.module says it's not taking care of encoding or escaping and the caller is supposed to do so. Maybe someone can explain where it is supposed to happen?

/**
 * Builds a list of referenceable nodes suitable for the '#option' FAPI property.
 *
 * Warning: the function does NOT take care of encoding or escaping the node
 * titles. Proper massaging needs to be performed by the caller, according to
 * the destination FAPI '#type' (radios / checkboxes / select).
 *
 * @param $field
 *   The field definition.
 * @param $flat
 *   Whether optgroups are allowed.
 *
 * @return
 *   An array of referenceable node titles, keyed by node id. If the $flat
 *   parameter is TRUE, the list might be nested by optgroup first.
 */
function _node_reference_options($field, $flat = TRUE) {
  $references = node_reference_potential_references($field);

  $options = array();
  foreach ($references as $key => $value) {
    if (empty($value['group']) || $flat) {
      $options[$key] = $value['rendered'];
    }
    else {
      // The group name, displayed in selects, cannot contain tags, and should
      // have HTML entities unencoded.
      $group = html_entity_decode(strip_tags($value['group']), ENT_QUOTES);
      $options[$group][$key] = $value['rendered'];
    }
  }

  return $options;
}
alexverb’s picture

If we use $value['title'] instead of $value['rendered'] there is no problem.
If we keep $value['rendered'], I think it should be decoded like $value['group'] is.

antiorario’s picture

Seems fixed in 7.x-2.x-dev.

jfhovinne’s picture

Status: Active » Fixed

I confirm the bug doesn't appear anymore after upgrading to 7.x-2.x-dev.

alexverb’s picture

Yup, looks like there has been chosen to decode the string. Works for me too.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Made the html entity display properly using code tags.