Changeset View
Changeset View
Standalone View
Standalone View
src/include/rcube_imap_generic.php
Show First 20 Lines • Show All 3,781 Lines • ▼ Show 20 Lines | |||||
public static function tokenizeResponse(&$str, $num=0) | public static function tokenizeResponse(&$str, $num=0) | ||||
{ | { | ||||
$result = array(); | $result = array(); | ||||
while (!$num || count($result) < $num) { | while (!$num || count($result) < $num) { | ||||
// remove spaces from the beginning of the string | // remove spaces from the beginning of the string | ||||
$str = ltrim($str); | $str = ltrim($str); | ||||
// empty string | |||||
if ($str === '' || $str === null) { | |||||
break; | |||||
} | |||||
switch ($str[0]) { | switch ($str[0]) { | ||||
// String literal | // String literal | ||||
case '{': | case '{': | ||||
if (($epos = strpos($str, "}\r\n", 1)) == false) { | if (($epos = strpos($str, "}\r\n", 1)) == false) { | ||||
// error | // error | ||||
} | } | ||||
if (!is_numeric(($bytes = substr($str, 1, $epos - 1)))) { | if (!is_numeric(($bytes = substr($str, 1, $epos - 1)))) { | ||||
Show All 31 Lines | public static function tokenizeResponse(&$str, $num=0) | ||||
break; | break; | ||||
case ')': | case ')': | ||||
$str = substr($str, 1); | $str = substr($str, 1); | ||||
return $result; | return $result; | ||||
// String atom, number, astring, NIL, *, % | // String atom, number, astring, NIL, *, % | ||||
default: | default: | ||||
// empty string | |||||
if ($str === '' || $str === null) { | |||||
break 2; | |||||
} | |||||
// excluded chars: SP, CTL, ), DEL | // excluded chars: SP, CTL, ), DEL | ||||
// we do not exclude [ and ] (#1489223) | // we do not exclude [ and ] (#1489223) | ||||
if (preg_match('/^([^\x00-\x20\x29\x7F]+)/', $str, $m)) { | if (preg_match('/^([^\x00-\x20\x29\x7F]+)/', $str, $m)) { | ||||
$result[] = $m[1] == 'NIL' ? null : $m[1]; | $result[] = $m[1] == 'NIL' ? null : $m[1]; | ||||
$str = substr($str, strlen($m[1])); | $str = substr($str, strlen($m[1])); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 257 Lines • Show Last 20 Lines |