From 935cc9990048ff07aabe5c7e550399642598a8d3 Mon Sep 17 00:00:00 2001
From: Lorenz Schori <lo@znerol.ch>
Date: Mon, 5 Mar 2012 14:12:56 +0100
Subject: [PATCH] Prevent incomplete quoting by using drupal string functions

In SearchApiQuery::parseKeys drupal string functions are not used
consequently. As a result when a quoted term contains multibyte
characters, a closing quote character is not detected properly. This
patch fixes the problem by converting all string manipulation functions
within parseKeys to their drupal_* equivalents.
---
 includes/query.inc |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/includes/query.inc b/includes/query.inc
index 59b5309..7e47a45 100644
--- a/includes/query.inc
+++ b/includes/query.inc
@@ -468,8 +468,8 @@ class SearchApiQuery implements SearchApiQueryInterface {
             continue;
           }
           if ($quoted) {
-            if ($v[drupal_strlen($v)-1] == '"') {
-              $v = substr($v, 0, -1);
+            if (drupal_substr($v, -1) == '"') {
+              $v = drupal_substr($v, 0, -1);
               $str .= ' ' . $v;
               $ret[$k] = $str;
               $quoted = FALSE;
@@ -481,11 +481,11 @@ class SearchApiQuery implements SearchApiQueryInterface {
           }
           elseif ($v[0] == '"') {
             $len = drupal_strlen($v);
-            if ($len > 1 && $v[$len-1] == '"') {
-              $ret[$k] = substr($v, 1, -1);
+            if ($len > 1 && drupal_substr($v, -1) == '"') {
+              $ret[$k] = drupal_substr($v, 1, -1);
             }
             else {
-              $str = substr($v, 1);
+              $str = drupal_substr($v, 1);
               $quoted = TRUE;
               unset($ret[$k]);
             }
-- 
1.7.4.1

