Changeset 4041 in subversion


Ignore:
Timestamp:
Oct 5, 2010 3:14:57 PM (3 years ago)
Author:
alec
Message:
  • Fix handling of backslash as IMAP delimiter
Location:
trunk/roundcubemail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r4038 r4041  
    2222- Fix confirmation message isn't displayed after sending mail on Chrome (#1486177) 
    2323- Fix keyboard doesn't work with autocomplete list with Chrome (#1487029) 
     24- Fix handling of backslash as IMAP delimiter 
    2425 
    2526RELEASE 0.4.1 
  • trunk/roundcubemail/program/include/rcube_imap_generic.php

    r4035 r4041  
    424424            } 
    425425 
    426         if (!$this->getCapability('NAMESPACE')) { 
    427                 return false; 
    428             } 
    429  
    430             if (!$this->putLine("ns1 NAMESPACE")) { 
    431             return false; 
    432         } 
    433             do { 
    434                     $line = $this->readLine(1024); 
    435                     if (preg_match('/^\* NAMESPACE/', $line)) { 
    436                             $i    = 0; 
    437                             $line = $this->unEscape($line); 
    438                             $data = $this->parseNamespace(substr($line,11), $i, 0, 0); 
    439                     } 
    440             } while (!$this->startsWith($line, 'ns1', true, true)); 
    441  
    442             if (!is_array($data)) { 
     426            if (!is_array($data = $this->_namespace())) { 
    443427                return false; 
    444428            } 
     
    489473 
    490474            do { 
    491                     $line = $this->readLine(500); 
    492                     if ($line[0] == '*') { 
    493                             $line = rtrim($line); 
    494                             $a = rcube_explode_quoted_string(' ', $this->unEscape($line)); 
    495                             if ($a[0] == '*') { 
    496                                 $delimiter = str_replace('"', '', $a[count($a)-2]); 
    497                         } 
     475                    $line = $this->readLine(1024); 
     476                    if (preg_match('/^\* LIST \([^\)]*\) "*([^"]+)"* ""/', $line, $m)) { 
     477                $delimiter = $this->unEscape($m[1]); 
    498478                    } 
    499479            } while (!$this->startsWith($line, 'ghd', true, true)); 
     
    505485            // if that fails, try namespace extension 
    506486            // try to fetch namespace data 
     487            if (!is_array($data = $this->_namespace())) { 
     488            return false; 
     489        } 
     490 
     491            // extract user space data (opposed to global/shared space) 
     492            $user_space_data = $data[0]; 
     493            if (!is_array($user_space_data)) { 
     494                return false; 
     495            } 
     496 
     497            // get first element 
     498            $first_userspace = $user_space_data[0]; 
     499            if (!is_array($first_userspace)) { 
     500                return false; 
     501            } 
     502 
     503            // extract delimiter 
     504            $delimiter = $first_userspace[1]; 
     505 
     506            return $delimiter; 
     507    } 
     508 
     509    function _namespace() 
     510    { 
     511        if (!$this->getCapability('NAMESPACE')) { 
     512                return false; 
     513            } 
     514 
    507515            if (!$this->putLine("ns1 NAMESPACE")) { 
    508516            return false; 
     
    513521                    if (preg_match('/^\* NAMESPACE/', $line)) { 
    514522                            $i = 0; 
    515                             $line = $this->unEscape($line); 
    516523                            $data = $this->parseNamespace(substr($line,11), $i, 0, 0); 
    517524                    } 
     
    522529            } 
    523530 
    524             // extract user space data (opposed to global/shared space) 
    525             $user_space_data = $data[0]; 
    526             if (!is_array($user_space_data)) { 
    527                 return false; 
    528             } 
    529  
    530             // get first element 
    531             $first_userspace = $user_space_data[0]; 
    532             if (!is_array($first_userspace)) { 
    533                 return false; 
    534             } 
    535  
    536             // extract delimiter 
    537             $delimiter = $first_userspace[1]; 
    538  
    539             return $delimiter; 
     531        return $data; 
    540532    } 
    541533 
     
    16581650                            $folders[] = preg_replace(array('/^"/', '/"$/'), '', $this->unEscape($m[3])); 
    16591651                        // attributes 
    1660 //                      $attrib = explode(' ', $m[1]); 
     1652//                      $attrib = explode(' ', $this->unEscape($m[1])); 
    16611653                        // delimiter 
    1662 //                      $delim = $m[2]; 
     1654//                      $delim = $this->unEscape($m[2]); 
    16631655                    } 
    16641656            } while (!$this->startsWith($line, $key, true)); 
     
    21712163            $elem      = 0; 
    21722164 
    2173         for ($i;$i<$len;$i++) { 
     2165        for ($i; $i<$len; $i++) { 
    21742166                    $c = (string)$str[$i]; 
    21752167                    if ($c == '(' && !$in_quotes) { 
     
    21822174                            $i++; 
    21832175                            if ($in_quotes) { 
    2184                                     $data[$elem] .= $c.$str[$i]; 
     2176                                    $data[$elem] .= $str[$i]; 
    21852177                        } 
    21862178                    } else if ($c == '"') { 
Note: See TracChangeset for help on using the changeset viewer.