Fixed bug #14021: Simplify the code to get nested GET Parameters with TS
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_search.php
old mode 100755 (executable)
new mode 100644 (file)
index 347880d..92ff3e2
@@ -226,33 +226,32 @@ class tslib_search {
        function split($origSword, $specchars='+-', $delchars='+.,-')   {
                $sword = $origSword;
                $specs = '['.$this->quotemeta($specchars).']';
-               $delchars = '['.$this->quotemeta($delchars).']';
 
                        // As long as $sword is true (that means $sword MUST be reduced little by little until its empty inside the loop!)
                while ($sword)  {
-                       if (ereg('^"',$sword))  {               // There was a double-quote and we will then look for the ending quote.
-                               $sword = ereg_replace('^"','',$sword);          // Removes first double-quote
-                               ereg('^[^"]*',$sword,$reg);  // Removes everything till next double-quote
+                       if (preg_match('/^"/',$sword))  {               // There was a double-quote and we will then look for the ending quote.
+                               $sword = preg_replace('/^"/','',$sword);                // Removes first double-quote
+                               preg_match('/^[^"]*/',$sword,$reg);  // Removes everything till next double-quote
                                $value[] = $reg[0];  // reg[0] is the value, should not be trimmed
-                               $sword = ereg_replace('^'.$this->quotemeta($reg[0]),'',$sword);
-                               $sword = trim(ereg_replace('^"','',$sword));            // Removes last double-quote
-                       } elseif (ereg('^'.$specs,$sword,$reg)) {
+                               $sword = preg_replace('/^'.$this->quotemeta($reg[0]).'/','',$sword);
+                               $sword = trim(preg_replace('/^"/','',$sword));          // Removes last double-quote
+                       } elseif (preg_match('/^'.$specs.'/',$sword,$reg)) {
                                $value[] = $reg[0];
-                               $sword = trim(ereg_replace('^'.$specs,'',$sword));              // Removes = sign
-                       } elseif (ereg('[\+\-]',$sword)) {      // Check if $sword contains + or -
+                               $sword = trim(preg_replace('/^'.$specs.'/','',$sword));         // Removes = sign
+                       } elseif (preg_match('/[\+\-]/',$sword)) {      // Check if $sword contains + or -
                                        // + and - shall only be interpreted as $specchars when there's whitespace before it
                                        // otherwise it's included in the searchword (e.g. "know-how")
                                $a_sword = explode(' ',$sword); // explode $sword to single words
                                $word = array_shift($a_sword);  // get first word
-                               $word = ereg_replace($delchars.'$','',$word);           // Delete $delchars at end of string
+                               $word = rtrim($word, $delchars);                // Delete $delchars at end of string
                                $value[] = $word;       // add searchword to values
                                $sword = implode(' ',$a_sword); // re-build $sword
                        } else {
                                        // There are no double-quotes around the value. Looking for next (space) or special char.
-                               ereg('^[^ '.$this->quotemeta($specchars).']*',$sword,$reg);
-                               $word = ereg_replace($delchars.'$','',trim($reg[0]));           // Delete $delchars at end of string
+                               preg_match('/^[^ '.$this->quotemeta($specchars).']*/',$sword,$reg);
+                               $word = rtrim(trim($reg[0]), $delchars);                // Delete $delchars at end of string
                                $value[] = $word;
-                               $sword = trim(ereg_replace('^'.$this->quotemeta($reg[0]),'',$sword));
+                               $sword = trim(preg_replace('/^'.$this->quotemeta($reg[0]).'/','',$sword));
                        }
                }