Fix Double Encoded %20 in Drupal Apache Solr Search

  • Published by steve on 28 February 2017.

This is difficult to troubleshoot because there are a variety of patches aimed at fixing this issue depending on the version of PHP your server is running. This relates to version 7.x-1.x

For my main server I required this patch
diff --git a/apachesolr_search.pages.inc b/apachesolr_search.pages.inc
index f4c8ac4..f61e8ad 100644
--- a/apachesolr_search.pages.inc
+++ b/apachesolr_search.pages.inc
@@ -99,8 +99,8 @@ function apachesolr_search_custom_page_search_form_submit(&$form, &$form_state)
// Also encode slashes so we don't get akward situations when obtaining the
// search key. We can't use drupal_encode_path because for "aestetic" reasons
// they don't encode slashes...
- $redirect_value = rawurlencode($form_state['values']['keys']);
-
+ $redirect_value = trim(str_replace("/","%2f",$form_state['values']['keys']));
+
if (strlen($form_state['values']['keys'])) {
$redirect .= '/' . $redirect_value;
}

You can also check out https://www.drupal.org/files/issues/2626686.apachesolr.search-terms-titl...

Here is the thread on Drupal's website: https://www.drupal.org/node/2626686