Changeset 4423 in subversion
- Timestamp:
- Jan 18, 2011 6:50:46 AM (2 years ago)
- Location:
- trunk/plugins/managesieve
- Files:
-
- 2 edited
-
Changelog (modified) (1 diff)
-
lib/rcube_sieve.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/managesieve/Changelog
r4241 r4423 2 2 - Fixed parsing of scripts with \r\n line separator 3 3 - Apply forgotten changes for form errors handling 4 - Fix multi-line strings parsing (#1487685) 4 5 5 6 * version 2.10 [2010-10-10] -
trunk/plugins/managesieve/lib/rcube_sieve.php
r4241 r4423 586 586 array_push($exts, $action['type']); 587 587 if (strpos($action['target'], "\n")!==false) 588 $script .= "\t".$action['type']." text:\n" . $action['target'] . "\n.\n;\n"; 588 $script .= "\t".$action['type']." text:\n" 589 . $this->_escape_multiline_string($action['target']) . "\n.\n;\n"; 589 590 else 590 $script .= "\t".$action['type']." \"" . $this->_escape_string($action['target']) . "\";\n"; 591 $script .= "\t".$action['type']." \"" 592 . $this->_escape_string($action['target']) . "\";\n"; 591 593 break; 592 594 case 'keep': … … 611 613 $script .= " :mime"; 612 614 if (strpos($action['reason'], "\n")!==false) 613 $script .= " text:\n" . $ action['reason']. "\n.\n;\n";615 $script .= " text:\n" . $this->_escape_multiline_string($action['reason']) . "\n.\n;\n"; 614 616 else 615 617 $script .= " \"" . $this->_escape_string($action['reason']) . "\";\n"; … … 910 912 $content = trim($content); 911 913 912 if (preg_match('/^text:(.*)\.$/sm', $content, $matches)) 913 $text = trim($matches[1]); 914 else if (preg_match('/^"(.*)"$/', $content, $matches)) 914 // multi-line string 915 if (preg_match('/^(text:[\t\s\r]*\n)/', $content, $matches)) { 916 $content = substr($content, strlen($matches[1])); 917 $lines = preg_split('/(\r?\n)/', $content, -1, PREG_SPLIT_DELIM_CAPTURE); 918 $text = ''; 919 920 foreach ($lines as $line) { 921 // terminator 922 if ($line == '.') { 923 break; 924 } 925 // dot-stuffing 926 if ($line[0] == '.' && $line[1] == '.') { 927 $line = substr($line, 1); 928 } 929 $text .= $line; 930 } 931 $text = rtrim($text, "\r\n"); 932 } 933 // quoted string 934 else if (preg_match('/^"(.*)"$/', $content, $matches)) { 915 935 $text = str_replace('\"', '"', $matches[1]); 936 } 916 937 917 938 return $text; … … 919 940 920 941 /** 921 * Escape special chars in string value942 * Escape special chars in quoted string value 922 943 * 923 944 * @param string Text … … 928 949 929 950 if (is_array($content)) { 930 for ($x=0, $y=sizeof($content); $x<$y; $x++) 951 for ($x=0, $y=sizeof($content); $x<$y; $x++) { 931 952 $content[$x] = preg_replace(array_keys($replace), 932 953 array_values($replace), $content[$x]); 954 } 933 955 934 956 return $content; 935 957 } 936 else 958 else { 937 959 return preg_replace(array_keys($replace), array_values($replace), $content); 960 } 961 } 962 963 /** 964 * Escape special chars in multi-line string value 965 * 966 * @param string Text 967 */ 968 private function _escape_multiline_string($content) 969 { 970 $lines = preg_split('/(\r?\n)/', $content, -1, PREG_SPLIT_DELIM_CAPTURE); 971 972 foreach ($lines as $idx => $line) { 973 // dot-stuffing 974 if ($line[0] == '.') { 975 $lines[$idx] = '.' . $line; 976 } 977 } 978 979 return implode($lines); 938 980 } 939 981
Note: See TracChangeset
for help on using the changeset viewer.
