search terms in search page title get double escaped

Created on 1 December 2015, over 8 years ago
Updated 19 July 2023, 11 months ago

When setting the title of a custom search page, you can use the token '%terms' to insert the user's search terms into the title.

However, these get output with double escaping. For example, a search for "<>chief O'Brien<b>" produces the page title: "Search: &lt;b&gt;Chief O&#039;Brien&lt;b&gt;". In particular, the apostrophe is output incorrectly.

The source of this bug is in apachesolr_search_get_value_title(). This is used as a title callback for the search page, and in apachesolr_search_menu_alter() is passed to the 'title callback' property of the menu items.

apachesolr_search_get_value_title() uses t() with a '@terms' placeholder, which runs the search terms through check_plain().

However, drupal_get_title() already has provision for sanitizing the page title, unless drupal_set_title() was called with the PASS_THROUGH option. We can't change the call to drupal_set_title(), as we're providing a menu title callback, so we shouldn't be escaping the string ourselves, but returning it raw.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024