Changeset 4562 in subversion
- Timestamp:
- Feb 18, 2011 6:00:48 AM (2 years ago)
- Location:
- trunk/plugins/managesieve
- Files:
-
- 2 edited
-
Changelog (modified) (1 diff)
-
lib/Net/Sieve.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/managesieve/Changelog
r4536 r4562 1 1 - Fix fileinto target is always INBOX (#1487776) 2 2 - Fix escaping of backslash character in quoted strings (#1487780) 3 - Fix handling of non-safe characters (double-quote, backslash) 4 or UTF-8 characters (dovecot's implementation bug workaround) 5 in script names 3 6 4 7 * version 4.0 [2011-02-10] -
trunk/plugins/managesieve/lib/Net/Sieve.php
r4495 r4562 476 476 return PEAR::raiseError('Not currently in TRANSACTION state', 1); 477 477 } 478 if (PEAR::isError($res = $this->_doCmd(sprintf('HAVESPACE "%s" %d', $scriptname, $size)))) { 478 479 $command = sprintf('HAVESPACE %s %d', $this->_escape($scriptname), $size); 480 if (PEAR::isError($res = $this->_doCmd($command))) { 479 481 return $res; 480 482 } … … 741 743 return PEAR::raiseError('Not currently in AUTHORISATION state', 1); 742 744 } 743 if (PEAR::isError($res = $this->_doCmd(sprintf('DELETESCRIPT "%s"', $scriptname)))) { 745 746 $command = sprintf('DELETESCRIPT %s', $this->_escape($scriptname)); 747 if (PEAR::isError($res = $this->_doCmd($command))) { 744 748 return $res; 745 749 } … … 760 764 } 761 765 762 if (PEAR::isError($res = $this->_doCmd(sprintf('GETSCRIPT "%s"', $scriptname)))) { 766 $command = sprintf('GETSCRIPT %s', $this->_escape($scriptname)); 767 if (PEAR::isError($res = $this->_doCmd($command))) { 763 768 return $res; 764 769 } … … 780 785 return PEAR::raiseError('Not currently in AUTHORISATION state', 1); 781 786 } 782 if (PEAR::isError($res = $this->_doCmd(sprintf('SETACTIVE "%s"', $scriptname)))) { 787 788 $command = sprintf('SETACTIVE "%s"', $this->_escape($scriptname)); 789 if (PEAR::isError($res = $this->_doCmd($command))) { 783 790 return $res; 784 791 } 792 785 793 $this->_activeScript = $scriptname; 786 794 return true; … … 809 817 foreach ($res as $value) { 810 818 if (preg_match('/^"(.*)"( ACTIVE)?$/i', $value, $matches)) { 811 $scripts[] = $matches[1]; 819 $script_name = stripslashes($matches[1]); 820 $scripts[] = $script_name; 812 821 if (!empty($matches[2])) { 813 $activescript = $ matches[1];822 $activescript = $script_name; 814 823 } 815 824 } … … 834 843 835 844 $stringLength = $this->_getLineLength($scriptdata); 836 837 if (PEAR::isError($res = $this->_doCmd(sprintf("PUTSCRIPT \"%s\" {%d+}\r\n%s", $scriptname, $stringLength, $scriptdata)))) { 845 $command = sprintf("PUTSCRIPT %s {%d+}\r\n%s", 846 $this->_escape($scriptname), $stringLength, $scriptdata); 847 848 if (PEAR::isError($res = $this->_doCmd($command))) { 838 849 return $res; 839 850 } … … 1214 1225 1215 1226 /** 1227 * Convert string into RFC's quoted-string or literal-c2s form 1228 * 1229 * @param string $string The string to convert. 1230 * 1231 * @return string Result string 1232 */ 1233 function _escape($string) 1234 { 1235 // Some implementations doesn't allow UTF-8 characters in quoted-string 1236 // It's safe to use literal-c2s 1237 if (preg_match('/[^\x01-\x09\x0B-\x0C\x0E-\x7F]/', $string)) { 1238 return sprintf("{%d+}\r\n%s", $this->_getLineLength($string), $string); 1239 } 1240 1241 return '"' . addcslashes($string, '\\"') . '"'; 1242 } 1243 1244 /** 1216 1245 * Write debug text to the current debug output handler. 1217 1246 *
Note: See TracChangeset
for help on using the changeset viewer.
