]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4139 if no mbstring extension we strip characters for display with search
authorCash Costello <cash.costello@gmail.com>
Tue, 29 Nov 2011 00:44:20 +0000 (19:44 -0500)
committercash <cash.costello@gmail.com>
Tue, 29 Nov 2011 02:44:02 +0000 (21:44 -0500)
mod/search/pages/search/index.php
mod/search/views/default/search/search_box.php

index c4e8d2219b1e5cc32b09a61d7ef5e80e0778a9a7..efa3ec0378c8eeebb749f34678409e4a68234dc6 100644 (file)
@@ -19,7 +19,12 @@ $query = stripslashes(get_input('q', get_input('tag', '')));
 
 // @todo - create function for sanitization of strings for display in 1.8
 // encode <,>,&, quotes and characters above 127
-$display_query = mb_convert_encoding($query, 'HTML-ENTITIES', 'UTF-8');
+if (function_exists('mb_convert_encoding')) {
+       $display_query = mb_convert_encoding($query, 'HTML-ENTITIES', 'UTF-8');
+} else {
+       // if no mbstring extension, we just strip characters
+       $display_query = preg_replace("/[^\x01-\x7F]/", "", $query);
+}
 $display_query = htmlspecialchars($display_query, ENT_QUOTES, 'UTF-8', false);
 
 // check that we have an actual query
index 9440dd1de97fbee3c62bce832ee9bcc445acca51..87d59519c3cd9f6c60d9946d45d7e8bb317ec1c1 100644 (file)
@@ -24,7 +24,12 @@ $value = stripslashes($value);
 
 // @todo - create function for sanitization of strings for display in 1.8
 // encode <,>,&, quotes and characters above 127
-$display_query = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
+if (function_exists('mb_convert_encoding')) {
+       $display_query = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
+} else {
+       // if no mbstring extension, we just strip characters
+       $display_query = preg_replace("/[^\x01-\x7F]/", "", $value);
+}
 $display_query = htmlspecialchars($display_query, ENT_QUOTES, 'UTF-8', false);