Changeset 6d0ada3 in github
- Timestamp:
- Aug 9, 2011 5:46:54 AM (22 months ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 2185899
- Parents:
- efc24a5
- Files:
-
- 6 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/rcube_imap.php (modified) (3 diffs)
-
program/include/rcube_smtp.php (modified) (3 diffs)
-
program/lib/Mail/mimePart.php (modified) (3 diffs)
-
program/steps/mail/sendmail.inc (modified) (3 diffs)
-
tests/maildecode.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r359e19a r6d0ada3 2 2 =========================== 3 3 4 - Fix handling of email addresses with quoted local part (#1487939) 4 5 - Fix EOL character in vCard exports (#1487873) 5 6 - Added optional "multithreading" autocomplete feature -
program/include/rcube_imap.php
r1cd3626 r6d0ada3 4761 4761 $result = array(); 4762 4762 4763 // simplified regexp, supporting quoted local part 4764 $email_rx = '(\S+|("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+"))@\S+'; 4765 4763 4766 foreach ($str as $key => $val) { 4764 4767 $name = ''; … … 4766 4769 $val = trim($val); 4767 4770 4768 if (preg_match('/(.*)<( \S+@\S+)>$/', $val, $m)) {4771 if (preg_match('/(.*)<('.$email_rx.')>$/', $val, $m)) { 4769 4772 $address = $m[2]; 4770 4773 $name = trim($m[1]); … … 4780 4783 // dequote and/or decode name 4781 4784 if ($name) { 4782 if ($name[0] == '"' ) {4785 if ($name[0] == '"' && $name[strlen($name)-1] == '"') { 4783 4786 $name = substr($name, 1, -1); 4784 4787 $name = stripslashes($name); -
program/include/rcube_smtp.php
r462de2d r6d0ada3 440 440 if (is_array($recipients)) 441 441 $recipients = implode(', ', $recipients); 442 442 443 443 $addresses = array(); 444 444 $recipients = rcube_explode_quoted_string(',', $recipients); … … 447 447 while (list($k, $recipient) = each($recipients)) 448 448 { 449 $a = explode(" ", $recipient);449 $a = rcube_explode_quoted_string(' ', $recipient); 450 450 while (list($k2, $word) = each($a)) 451 451 { … … 458 458 } 459 459 } 460 460 461 return $addresses; 461 462 } -
program/lib/Mail/mimePart.php
r53604a0 r6d0ada3 132 132 var $_eol = "\r\n"; 133 133 134 134 135 /** 135 136 * Constructor. … … 801 802 // Structured header (make sure addr-spec inside is not encoded) 802 803 if (!empty($separator)) { 804 // Simple e-mail address regexp 805 $email_regexp = '(\S+|("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+"))@\S+'; 806 803 807 $parts = Mail_mimePart::_explodeQuotedString($separator, $value); 804 808 $value = ''; … … 818 822 819 823 // let's find phrase (name) and/or addr-spec 820 if (preg_match('/^< \S+@\S+>$/', $part)) {824 if (preg_match('/^<' . $email_regexp . '>$/', $part)) { 821 825 $value .= $part; 822 } else if (preg_match('/^ \S+@\S+$/', $part)) {826 } else if (preg_match('/^' . $email_regexp . '$/', $part)) { 823 827 // address without brackets and without name 824 828 $value .= $part; 825 } else if (preg_match('/<* \S+@\S+>*$/', $part, $matches)) {829 } else if (preg_match('/<*' . $email_regexp . '>*$/', $part, $matches)) { 826 830 // address with name (handle name) 827 831 $address = $matches[0]; -
program/steps/mail/sendmail.inc
r340546c r6d0ada3 144 144 global $EMAIL_FORMAT_ERROR, $RECIPIENT_COUNT; 145 145 146 $regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/', '/(\S{1})(<\S+@\S+>)/U'); 146 // simplified email regexp, supporting quoted local part 147 $email_regexp = '(\S+|("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+"))@\S+'; 148 149 $regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/', '/(\S{1})(<'.$email_regexp.'>)/U'); 147 150 $replace = array(', ', ', ', '', ',', '\\1 \\2'); 148 151 … … 156 159 $item = trim($item); 157 160 // address in brackets without name (do nothing) 158 if (preg_match('/^< \S+@\S+>$/', $item)) {161 if (preg_match('/^<'.$email_regexp.'>$/', $item)) { 159 162 $item = rcube_idn_to_ascii($item); 160 163 $result[] = $item; 161 164 // address without brackets and without name (add brackets) 162 } else if (preg_match('/^ \S+@\S+$/', $item)) {165 } else if (preg_match('/^'.$email_regexp.'$/', $item)) { 163 166 $item = rcube_idn_to_ascii($item); 164 167 $result[] = '<'.$item.'>'; 165 168 // address with name (handle name) 166 } else if (preg_match('/ \S+@\S+>*$/', $item, $matches)) {169 } else if (preg_match('/'.$email_regexp.'>*$/', $item, $matches)) { 167 170 $address = $matches[0]; 168 171 $name = str_replace($address, '', $item); … … 173 176 } 174 177 $address = rcube_idn_to_ascii($address); 175 if (!preg_match('/^< \S+@\S+>$/', $address))178 if (!preg_match('/^<'.$email_regexp.'>$/', $address)) 176 179 $address = '<'.$address.'>'; 177 180 -
tests/maildecode.php
r6c68cbd r6d0ada3 45 45 17 => 'test@domain.tld (comment)', 46 46 18 => '"Test,Test" <test@domain.tld>', 47 // 1487939 48 19 => 'Test <"test test"@domain.tld>', 47 49 ); 48 50 … … 67 69 17 => array(1, '', 'test@domain.tld'), 68 70 18 => array(1, 'Test,Test', 'test@domain.tld'), 71 19 => array(1, 'Test', '"test test"@domain.tld'), 69 72 ); 70 73 … … 74 77 $this->assertEqual($results[$idx][0], count($res), "Rows number in result for header: " . $header); 75 78 $this->assertEqual($results[$idx][1], $res[1]['name'], "Name part decoding for header: " . $header); 76 $this->assertEqual($results[$idx][2], $res[1]['mailto'], " Namepart decoding for header: " . $header);79 $this->assertEqual($results[$idx][2], $res[1]['mailto'], "Email part decoding for header: " . $header); 77 80 } 78 81 }
Note: See TracChangeset
for help on using the changeset viewer.
