Changeset 2569 in subversion


Ignore:
Timestamp:
May 29, 2009 8:08:58 AM (4 years ago)
Author:
alec
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/lib/imap.inc

    r2563 r2569  
    8484                - handling connection startup response 
    8585                - added UID EXPUNGE support 
    86                 - fixed problem with double quote at the end of folder name in LIST and LSUB  
     86                - fixed problem with double quotes and spaces in folder names in LIST and LSUB  
    8787 
    8888********************************************************/ 
     
    256256} 
    257257 
    258 function iil_MultLine($fp, $line) { 
     258function iil_MultLine($fp, $line, $escape=false) { 
    259259        $line = chop($line); 
    260260        if (preg_match('/\{[0-9]+\}$/', $line)) { 
     
    267267                        $out .= $line; 
    268268                } 
    269                 $line = $a[1][0] . "\"$out\""; 
     269 
     270                $line = $a[1][0] . '"' . ($escape ? iil_Escape($out) : $out) . '"'; 
    270271//              console('[...] '. $out); 
    271272        } 
     
    727728 
    728729function iil_ExplodeQuotedString($delimiter, $string) { 
    729         $quotes = explode('"', $string); 
    730         while ( list($key, $val) = each($quotes)) { 
    731                 if (($key % 2) == 1) { 
    732                         $quotes[$key] = str_replace($delimiter, "_!@!_", $quotes[$key]); 
    733                 } 
    734         } 
    735         $string = implode('"', $quotes); 
    736          
    737         $result = explode($delimiter, $string); 
    738         while ( list($key, $val) = each($result) ) { 
    739                 $result[$key] = str_replace('_!@!_', $delimiter, $result[$key]); 
    740         } 
    741      
     730        $result = array(); 
     731        $strlen = strlen($string); 
     732           
     733        for ($q=$p=$i=0; $i < $strlen; $i++) { 
     734                if ($string[$i] == "\"" && $string[$i-1] != "\\") { 
     735                        $q = $q ? false : true; 
     736                } 
     737                else if (!$q && preg_match("/$delimiter/", $string[$i])) { 
     738                        $result[] = substr($string, $p, $i - $p); 
     739                        $p = $i + 1; 
     740                } 
     741        } 
     742 
     743        $result[] = substr($string, $p); 
    742744        return $result; 
    743745} 
     
    15301532                return false; 
    15311533        } 
    1532                  
     1534 
    15331535        if ($add) 
    15341536                $add = ' '.strtoupper(trim($add)); 
     
    21502152        do { 
    21512153                $line = iil_ReadLine($fp, 500); 
    2152                 $line = iil_MultLine($fp, $line); 
     2154                $line = iil_MultLine($fp, $line, true); 
    21532155 
    21542156                $a = explode(' ', $line); 
     
    21582160                        $a = iil_ExplodeQuotedString(' ', $line); 
    21592161                        // last string is folder name 
    2160                         $folder = preg_replace(array('/^"/', '/"$/'), '', $a[count($a)-1]); 
     2162                        $folder = preg_replace(array('/^"/', '/"$/'), '', iil_UnEscape($a[count($a)-1])); 
    21612163             
    21622164                        if (empty($ignore) || (!empty($ignore) 
     
    22152217        do { 
    22162218                $line = iil_ReadLine($fp, 500); 
    2217                 $line = iil_MultLine($fp, $line); 
     2219                $line = iil_MultLine($fp, $line, true); 
    22182220                $a    = explode(' ', $line); 
    22192221         
     
    22232225                        // split one line 
    22242226                        $a = iil_ExplodeQuotedString(' ', $line); 
    2225              
    22262227                        // last string is folder name 
    2227                         $folder = preg_replace(array('/^"/', '/"$/'), '', $a[count($a)-1]); 
     2228                        $folder = preg_replace(array('/^"/', '/"$/'), '', iil_UnEscape($a[count($a)-1])); 
    22282229         
    22292230                        if ((!in_array($folder, $folders)) && (empty($ignore) 
     
    26232624                } 
    26242625        } 
     2626        console('----'.$result); 
    26252627        return $result; 
    26262628} 
Note: See TracChangeset for help on using the changeset viewer.