Changeset 8acab00 in github
- Timestamp:
- Sep 8, 2006 8:34:25 AM (7 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 7139e33
- Parents:
- 70d4b9a
- Files:
-
- 2 edited
-
CHANGELOG (modified) (1 diff)
-
program/lib/Mail/mime.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
re170b4b r8acab00 1 1 CHANGELOG RoundCube Webmail 2 2 --------------------------- 3 4 2006/09/08 (thomasb) 5 ---------- 6 - Fixed safe_mode problems (Bug #1418381) 7 - Fixed wrong header encoding (Bug #1483976) 8 3 9 4 10 2006/09/07 (thomasb) -
program/lib/Mail/mime.php
ra8435bd r8acab00 827 827 //quoted-printable encoding has been selected 828 828 829 //Generate the header using the specified params and dynamicly 830 //determine the maximum length of such strings. 831 //75 is the value specified in the RFC. The -2 is there so 832 //the later regexp doesn't break any of the translated chars. 833 $prefix = '=?' . $this->_build_params['head_charset'] . '?Q?'; 834 $suffix = '?='; 835 $maxLength = 75 - strlen($prefix . $suffix) - 2; 836 $maxLength1stLine = $maxLength - strlen($hdr_name); 837 838 //Replace all special characters used by the encoder. 839 $search = array("=", "_", "?", " "); 840 $replace = array("=3D", "=5F", "=3F", "_"); 841 $hdr_value = str_replace($search, $replace, $hdr_value); 842 843 //Replace all extended characters (\x80-xFF) with their 844 //ASCII values. 845 $hdr_value = preg_replace( 846 '#([\x80-\xFF])#e', 847 '"=" . strtoupper(dechex(ord("\1")))', 848 $hdr_value 849 ); 850 //This regexp will break QP-encoded text at every $maxLength 851 //but will not break any encoded letters. 852 $reg1st = "|(.{0,$maxLength})[^\=]|"; 853 $reg2nd = "|(.{0,$maxLength})[^\=]|"; 854 break; 829 preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $hdr_value, $matches); 830 foreach ($matches[1] as $value) { 831 $replacement = preg_replace('/([\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value); 832 $hdr_value = str_replace($value, '=?' . $this->_build_params['head_charset'] . '?Q?' . $replacement . '?=', $hdr_value); 833 } 855 834 } 856 //Begin with the regexp for the first line. 857 $reg = $reg1st; 858 $output = ""; 859 while ($hdr_value) { 860 //Split translated string at every $maxLength 861 //But make sure not to break any translated chars. 862 $found = preg_match($reg, $hdr_value, $matches); 863 864 //After this first line, we need to use a different 865 //regexp for the first line. 866 $reg = $reg2nd; 867 868 //Save the found part and encapsulate it in the 869 //prefix & suffix. Then remove the part from the 870 //$hdr_value variable. 871 if ($found){ 872 $part = $matches[0]; 873 $hdr_value = substr($hdr_value, strlen($matches[0])); 874 }else{ 875 $part = $hdr_value; 876 $hdr_value = ""; 877 } 878 879 //RFC 2047 specifies that any split header should be seperated 880 //by a CRLF SPACE. 881 if ($output){ 882 $output .= "\r\n "; 883 } 884 $output .= $prefix . $part . $suffix; 885 } 886 $hdr_value = $output; 887 } 835 } 836 888 837 $input[$hdr_name] = $hdr_value; 889 838 }
Note: See TracChangeset
for help on using the changeset viewer.
