Changeset e8a1b7e in github for program/lib/Mail/mimePart.php
- Timestamp:
- Sep 5, 2008 2:53:51 AM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 5ec762a
- Parents:
- 0dbac32
- File:
-
- 1 edited
-
program/lib/Mail/mimePart.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/lib/Mail/mimePart.php
r1c25366 re8a1b7e 389 389 * @param $charset The characterset of $value 390 390 * @param $language The language used in $value 391 * @param $maxLength The maximum length of a line. Defauls to 7 5391 * @param $maxLength The maximum length of a line. Defauls to 78 392 392 * 393 393 * @access private 394 394 */ 395 function _buildHeaderParam($name, $value, $charset=NULL, $language=NULL, $maxLength=75) 396 { 397 //If we find chars to encode, or if charset or language 398 //is not any of the defaults, we need to encode the value. 399 $shouldEncode = 0; 400 $secondAsterisk = ''; 401 if (preg_match('#([ \x80-\xFF \*\'\\%\t(\)\<\>\@\,\;\:\\\"/\[\]\?\=]){1}#', $value)) { 402 $shouldEncode = 1; 403 } elseif ($charset && (strtolower($charset) != 'us-ascii')) { 404 $shouldEncode = 1; 405 } elseif ($language && ($language != 'en' && $language != 'en-us')) { 406 $shouldEncode = 1; 407 } 408 if ($shouldEncode) { 409 $encValue = preg_replace('#([\x80-\xFF \*\'\%\t\(\)\<\>\@\,\;\:\\\"/\[\]\?\=])#e', '"%" . strtoupper(dechex(ord("\1")))', $value); 410 $value = "$charset'$language'$encValue"; 411 $secondAsterisk = '*'; 412 } 413 $header = " {$name}{$secondAsterisk}=\"{$value}\"; "; 395 function _buildHeaderParam($name, $value, $charset=NULL, $language=NULL, $maxLength=78) 396 { 397 // RFC 2183/2184/2822: 398 // value needs encoding if contains non-ASCII chars or is longer than 78 chars 399 400 if (preg_match('#[\x20-\x7E]#', $value)) { // ASCII 401 $quoted = addcslashes($value, '\\"'); 402 if (strlen($name) + strlen($quoted) + 6 <= $maxLength) 403 return " {$name}=\"{$quoted}\"; "; 404 } 405 406 $encValue = preg_replace('#([^\x20-\x7E])#e', '"%" . strtoupper(dechex(ord("\1")))', $value); 407 $value = "$charset'$language'$encValue"; 408 409 $header = " {$name}*=\"{$value}\"; "; 414 410 if (strlen($header) <= $maxLength) { 415 411 return $header; 416 412 } 417 413 418 $preLength = strlen(" {$name}*0 {$secondAsterisk}=\"");414 $preLength = strlen(" {$name}*0*=\""); 419 415 $sufLength = strlen("\";"); 420 416 $maxLength = MAX(16, $maxLength - $preLength - $sufLength - 2); … … 427 423 $found = preg_match($maxLengthReg, $value, $matches); 428 424 if ($found) { 429 $headers[] = " {$name}*{$headCount} {$secondAsterisk}=\"{$matches[0]}\"";425 $headers[] = " {$name}*{$headCount}*=\"{$matches[0]}\""; 430 426 $value = substr($value, strlen($matches[0])); 431 427 } else { 432 $headers[] = " {$name}*{$headCount} {$secondAsterisk}=\"{$value}\"";428 $headers[] = " {$name}*{$headCount}*=\"{$value}\""; 433 429 $value = ""; 434 430 }
Note: See TracChangeset
for help on using the changeset viewer.
