From ad2cfa7b38bc2ce92191163bc4f0d4f331c34ab0 Mon Sep 17 00:00:00 2001 From: Alexander Dreweke Date: Sun, 17 Nov 2013 00:15:27 +0100 Subject: [PATCH] check collation for caseinsensitive search --- inc/vProperty.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/inc/vProperty.php b/inc/vProperty.php index 9ef2dc6..7a634ce 100644 --- a/inc/vProperty.php +++ b/inc/vProperty.php @@ -274,12 +274,17 @@ class vProperty extends vObject { * * @return string The name for the property. */ - function TextMatch( $search ) { - if ( isset($this->content) ) return strstr( $this->content, $search ); - return false; + function TextMatch( $search, $case_sensitive = true) { + if ( isset($this->content) ) { + if ($case_sensitive) { + return strstr( $this->content, $search ); + } else { + return stristr( $this->content, $search ); + } + } + return false; } - /** * Get the value of a parameter * @@ -446,7 +451,20 @@ class vProperty extends vObject { case 'urn:ietf:params:xml:ns:carddav:text-match': case 'urn:ietf:params:xml:ns:caldav:text-match': $search = $v->GetContent(); - $match = $this->TextMatch($search); + $case_sensitive = true; + $collation = $v->GetAttribute("collation"); + switch( strtolower($collation) ) { + case 'i;ascii-casemap': + case 'i;unicode-casemap': + $case_sensitive = false; + break; + case 'i;octet': + default: + $case_sensitive = true; + break; + } + + $match = $this->TextMatch($search, $case_sensitive); $negate = $v->GetAttribute("negate-condition"); if ( isset($negate) && strtolower($negate) == "yes" ) { $match = !$match; -- 2.11.4.GIT