URL Encoded Entities and Faceted Browsing

Created on 22 July 2010, over 14 years ago
Updated 7 August 2024, 5 months ago

The faceted browsing mechanism does not work if the facet contains an ampersand ("&"). The reason for this is that drupal_urlencode(), which is used in the l() function call, double-escapes ampersands with "%2526;". When clicking on a facet to search the query will be sent off as an already-encoded entity: "Foo %26 Bar", instead of "Foo & Bar".

I have tracked this down to the link being built in theme_faceted_search_ui_category().


function theme_faceted_search_ui_category($category, $path) {
  // Note: get_label() is responsible for filtering its returned string.
  if ($path) {
    //$label = '<a href="' . rawurlencode($path) . '">' . $category->get_label(TRUE) . "</a>";
    $label = l($category->get_label(TRUE), $path, array('html' => TRUE));
  }
  else {
    $label = $category->get_label(TRUE);
  }

  // Note: Tooltips rely on class 'faceted-search-category'.
  return '<span class="faceted-search-category">'. $label .'<span class="faceted-search-count">&nbsp;('. $category->get_count() .')</span></span>';
}

Any thoughts on how to fix this?

🐛 Bug report
Status

Active

Version

1.0

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

No activities found.

Production build 0.71.5 2024