Changeset 4980 in subversion
- Timestamp:
- Jul 27, 2011 2:21:49 PM (23 months ago)
- Location:
- trunk/roundcubemail/program/include
- Files:
-
- 2 edited
-
rcube_imap.php (modified) (4 diffs)
-
rcube_mime_struct.php (modified) (6 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/rcube_imap.php
r4978 r4980 2164 2164 $mime_part_headers[] = $tmp_part_id; 2165 2165 } 2166 else if (in_array('name', (array)$part[$i][2]) && (empty($part[$i][3]) || $part[$i][3]=='NIL')) {2166 else if (in_array('name', (array)$part[$i][2]) && empty($part[$i][3])) { 2167 2167 $mime_part_headers[] = $tmp_part_id; 2168 2168 } … … 2232 2232 2233 2233 // read content encoding 2234 if (!empty($part[5]) && $part[5]!='NIL') {2234 if (!empty($part[5])) { 2235 2235 $struct->encoding = strtolower($part[5]); 2236 2236 $struct->headers['content-transfer-encoding'] = $struct->encoding; … … 2238 2238 2239 2239 // get part size 2240 if (!empty($part[6]) && $part[6]!='NIL')2240 if (!empty($part[6])) 2241 2241 $struct->size = intval($part[6]); 2242 2242 … … 2265 2265 2266 2266 // get part ID 2267 if (!empty($part[3]) && $part[3]!='NIL') {2267 if (!empty($part[3])) { 2268 2268 $struct->content_id = $part[3]; 2269 2269 $struct->headers['content-id'] = $part[3]; -
trunk/roundcubemail/program/include/rcube_mime_struct.php
- Property svn:keywords set to Id Author
r4410 r4980 7 7 | | 8 8 | This file is part of the Roundcube Webmail client | 9 | Copyright (C) 2005-201 0, The Roundcube Dev Team |9 | Copyright (C) 2005-2011, The Roundcube Dev Team | 10 10 | Licensed under the GNU GPL | 11 11 | | … … 49 49 $line = str_replace(')(', ') (', $line); 50 50 51 $struct = self::parseBSString($line);51 $struct = rcube_imap_generic::tokenizeResponse($line); 52 52 if (!is_array($struct[0]) && (strcasecmp($struct[0], 'message') == 0) 53 53 && (strcasecmp($struct[1], 'rfc822') == 0)) { … … 79 79 return $part_a[0]; 80 80 } 81 81 82 82 return 'other'; 83 83 } … … 90 90 return $part_a[5]; 91 91 } 92 92 93 93 return ''; 94 94 } … … 109 109 } 110 110 } 111 111 112 112 return ''; 113 113 } … … 143 143 } 144 144 145 private function closingParenPos($str, $start)146 {147 $level = 0;148 $len = strlen($str);149 $in_quote = 0;150 151 for ($i=$start; $i<$len; $i++) {152 if ($str[$i] == '"' && $str[$i-1] != "\\") {153 $in_quote = ($in_quote + 1) % 2;154 }155 if (!$in_quote) {156 if ($str[$i] == '(')157 $level++;158 else if (($level > 0) && ($str[$i] == ')'))159 $level--;160 else if (($level == 0) && ($str[$i] == ')'))161 return $i;162 }163 }164 }165 166 /*167 * Parses IMAP's BODYSTRUCTURE string into array168 */169 private function parseBSString($str)170 {171 $id = 0;172 $a = array();173 $len = strlen($str);174 $in_quote = 0;175 176 for ($i=0; $i<$len; $i++) {177 if ($str[$i] == '"') {178 $in_quote = ($in_quote + 1) % 2;179 } else if (!$in_quote) {180 // space means new element181 if ($str[$i] == ' ') {182 $id++;183 // skip additional spaces184 while ($str[$i+1] == ' ')185 $i++;186 // new part187 } else if ($str[$i] == '(') {188 $i++;189 $endPos = self::closingParenPos($str, $i);190 $partLen = $endPos - $i;191 if ($partLen < 0)192 break;193 $part = substr($str, $i, $partLen);194 $a[$id] = self::parseBSString($part); // send part string195 $i = $endPos;196 } else197 $a[$id] .= $str[$i]; //add to current element in array198 } else if ($in_quote) {199 if ($str[$i] == "\\") {200 $i++; // escape backslashes201 if ($str[$i] == '"' || $str[$i] == "\\")202 $a[$id] .= $str[$i];203 }204 else205 $a[$id] .= $str[$i]; //add to current element in array206 }207 }208 209 reset($a);210 return $a;211 }212 213 214 145 }
Note: See TracChangeset
for help on using the changeset viewer.
