Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

+1 -1
View File
@@ -51,7 +51,7 @@
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php 268 2009-05-20 13:25:45Z bfarber $
* @version CVS: $Id: JSON.php 8229 2011-03-31 10:17:44Z ips_terabyte $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
+1 -1
View File
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
+1 -1
View File
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
+63 -32
View File
@@ -48,7 +48,7 @@
* @author Aleksander Machniak <alec@php.net>
* @copyright 2003-2006 PEAR <pear-group@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version CVS: $Id: mime.php 297878 2010-04-12 10:57:34Z alec $
* @version CVS: $Id: mime.php 8229 2011-03-31 10:17:44Z ips_terabyte $
* @link http://pear.php.net/package/Mail_mime
*
* This class is based on HTML Mime Mail class from
@@ -63,7 +63,7 @@
*
* This package depends on PEAR to raise errors.
*/
require_once 'PEAR.php';
require_once 'PEAR.php';/*noLibHook*/
/**
* require Mail_mimePart
@@ -72,7 +72,7 @@ require_once 'PEAR.php';
* create all the different parts a mail can
* consist of.
*/
require_once 'Mail/mimePart.php';
require_once 'Mail/mimePart.php';/*noLibHook*/
/**
@@ -365,30 +365,28 @@ class Mail_mime
* Adds a file to the list of attachments.
*
* @param string $file The file name of the file to attach
* OR the file contents itself
* or the file contents itself
* @param string $c_type The content type
* @param string $name The filename of the attachment
* Only use if $file is the contents
* @param bool $isfile Whether $file is a filename or not
* Defaults to true
* @param string $encoding The type of encoding to use.
* Defaults to base64.
* Possible values: 7bit, 8bit, base64,
* or quoted-printable.
* @param bool $isfile Whether $file is a filename or not. Defaults to true
* @param string $encoding The type of encoding to use. Defaults to base64.
* Possible values: 7bit, 8bit, base64 or quoted-printable.
* @param string $disposition The content-disposition of this file
* Defaults to attachment.
* Possible values: attachment, inline.
* @param string $charset The character set used in the filename
* of this attachment.
* @param string $charset The character set of attachment's content.
* @param string $language The language of the attachment
* @param string $location The RFC 2557.4 location of the attachment
* @param string $n_encoding Encoding for attachment name (Content-Type)
* @param string $n_encoding Encoding of the attachment's name in Content-Type
* By default filenames are encoded using RFC2231 method
* Here you can set RFC2047 encoding (quoted-printable
* or base64) instead
* @param string $f_encoding Encoding for attachment filename (Content-Disposition)
* See $n_encoding description
* @param string $f_encoding Encoding of the attachment's filename
* in Content-Disposition header.
* @param string $description Content-Description header
* @param string $h_charset The character set of the headers e.g. filename
* If not specified, $charset will be used
*
* @return mixed True on success or PEAR_Error object
* @access public
@@ -404,7 +402,8 @@ class Mail_mime
$location = '',
$n_encoding = null,
$f_encoding = null,
$description = ''
$description = '',
$h_charset = null
) {
$bodyfile = null;
@@ -437,14 +436,15 @@ class Mail_mime
'body_file' => $bodyfile,
'name' => $filename,
'c_type' => $c_type,
'encoding' => $encoding,
'charset' => $charset,
'encoding' => $encoding,
'language' => $language,
'location' => $location,
'disposition' => $disposition,
'description' => $description,
'name_encoding' => $n_encoding,
'filename_encoding' => $f_encoding
'filename_encoding' => $f_encoding,
'headers_charset' => $h_charset,
);
return true;
@@ -621,7 +621,7 @@ class Mail_mime
$params['content_type'] = $value['c_type'];
$params['encoding'] = 'base64';
$params['disposition'] = 'inline';
$params['dfilename'] = $value['name'];
$params['filename'] = $value['name'];
$params['cid'] = $value['cid'];
$params['body_file'] = $value['body_file'];
$params['eol'] = $this->_build_params['eol'];
@@ -650,19 +650,25 @@ class Mail_mime
function &_addAttachmentPart(&$obj, $value)
{
$params['eol'] = $this->_build_params['eol'];
$params['dfilename'] = $value['name'];
$params['filename'] = $value['name'];
$params['encoding'] = $value['encoding'];
$params['content_type'] = $value['c_type'];
$params['body_file'] = $value['body_file'];
$params['disposition'] = isset($value['disposition']) ?
$value['disposition'] : 'attachment';
if ($value['charset']) {
// content charset
if (!empty($value['charset'])) {
$params['charset'] = $value['charset'];
}
if ($value['language']) {
// headers charset (filename, description)
if (!empty($value['headers_charset'])) {
$params['headers_charset'] = $value['headers_charset'];
}
if (!empty($value['language'])) {
$params['language'] = $value['language'];
}
if ($value['location']) {
if (!empty($value['location'])) {
$params['location'] = $value['location'];
}
if (!empty($value['name_encoding'])) {
@@ -842,14 +848,16 @@ class Mail_mime
if (isset($this->_headers['From'])) {
// Bug #11381: Illegal characters in domain ID
if (preg_match("|(@[0-9a-zA-Z\-\.]+)|", $this->_headers['From'], $matches)) {
if (preg_match('#(@[0-9a-zA-Z\-\.]+)#', $this->_headers['From'], $matches)) {
$domainID = $matches[1];
} else {
$domainID = "@localhost";
$domainID = '@localhost';
}
foreach ($this->_html_images as $i => $img) {
$this->_html_images[$i]['cid']
= $this->_html_images[$i]['cid'] . $domainID;
$cid = $this->_html_images[$i]['cid'];
if (!preg_match('#'.preg_quote($domainID).'$#', $cid)) {
$this->_html_images[$i]['cid'] = $cid . $domainID;
}
}
}
@@ -993,7 +1001,7 @@ class Mail_mime
$ret = null;
return $ret;
}
// Use saved boundary
if (!empty($this->_build_params['boundary'])) {
$boundary = $this->_build_params['boundary'];
@@ -1153,7 +1161,7 @@ class Mail_mime
// add required boundary parameter if not defined
if (preg_match('/^multipart\//i', $type)) {
if (empty($this->_build_params['boundary'])) {
$this->_build_params['boundary'] = '=_' . md5(rand() . microtime());
$this->_build_params['boundary'] = '=_' . md5(rand() . microtime());
}
$header .= ";$eol boundary=\"".$this->_build_params['boundary']."\"";
@@ -1188,6 +1196,24 @@ class Mail_mime
$this->_headers['From'] = $email;
}
/**
* Add an email to the To header
* (multiple calls to this method are allowed)
*
* @param string $email The email direction to add
*
* @return void
* @access public
*/
function addTo($email)
{
if (isset($this->_headers['To'])) {
$this->_headers['To'] .= ", $email";
} else {
$this->_headers['To'] = $email;
}
}
/**
* Add an email to the Cc (carbon copy) header
* (multiple calls to this method are allowed)
@@ -1367,18 +1393,23 @@ class Mail_mime
if ($headers['Content-Type'] == 'text/plain') {
// single-part message: add charset and encoding
$charset = 'charset=' . $this->_build_params['text_charset'];
// place charset parameter in the same line, if possible
// 26 = strlen("Content-Type: text/plain; ")
$headers['Content-Type']
.= ";$eol charset=" . $this->_build_params['text_charset'];
.= (strlen($charset) + 26 <= 76) ? "; $charset" : ";$eol $charset";
$headers['Content-Transfer-Encoding']
= $this->_build_params['text_encoding'];
} else if ($headers['Content-Type'] == 'text/html') {
// single-part message: add charset and encoding
$charset = 'charset=' . $this->_build_params['html_charset'];
// place charset parameter in the same line, if possible
$headers['Content-Type']
.= ";$eol charset=" . $this->_build_params['html_charset'];
.= (strlen($charset) + 25 <= 76) ? "; $charset" : ";$eol $charset";
$headers['Content-Transfer-Encoding']
= $this->_build_params['html_encoding'];
} else {
// multipart message: add charset and boundary
// multipart message: and boundary
if (!empty($this->_build_params['boundary'])) {
$boundary = $this->_build_params['boundary'];
} else if (!empty($this->_headers['Content-Type'])
+186 -48
View File
@@ -52,7 +52,7 @@
* @author Sean Coates <sean@php.net>
* @copyright 2003-2006 PEAR <pear-group@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version CVS: $Id: mimeDecode.php 288500 2009-09-21 05:32:32Z alan_k $
* @version CVS: $Id: mimeDecode.php 8229 2011-03-31 10:17:44Z ips_terabyte $
* @link http://pear.php.net/package/Mail_mime
*/
@@ -62,7 +62,7 @@
*
* This package depends on PEAR to raise errors.
*/
require_once 'PEAR.php';
require_once 'PEAR.php';/*noLibHook*/
/**
@@ -129,7 +129,7 @@ class Mail_mimeDecode extends PEAR
* @var boolean
* @access private
*/
var $_include_bodies;
var $_include_bodies;/*noLibHook*/
/**
* Flag to determine whether to decode bodies
@@ -154,7 +154,7 @@ class Mail_mimeDecode extends PEAR
* @var boolean
* @access private
*/
var $_rfc822_bodies;
var $_rfc822_bodies;/*noLibHook*/
/**
* Constructor.
@@ -197,7 +197,7 @@ class Mail_mimeDecode extends PEAR
function decode($params = null)
{
// determine if this method has been called statically
$isStatic = !(isset($this) && get_class($this) == __CLASS__);
$isStatic = empty($this) || !is_a($this, __CLASS__);
// Have we been called statically?
// If so, create an object and pass details to that.
@@ -247,6 +247,7 @@ class Mail_mimeDecode extends PEAR
$headers = $this->_parseHeaders($headers);
foreach ($headers as $value) {
$value['value'] = $this->_decode_headers ? $this->_decodeHeader($value['value']) : $value['value'];
if (isset($return->headers[strtolower($value['name'])]) AND !is_array($return->headers[strtolower($value['name'])])) {
$return->headers[strtolower($value['name'])] = array($return->headers[strtolower($value['name'])]);
$return->headers[strtolower($value['name'])][] = $value['value'];
@@ -259,8 +260,8 @@ class Mail_mimeDecode extends PEAR
}
}
reset($headers);
while (list($key, $value) = each($headers)) {
foreach ($headers as $key => $value) {
$headers[$key]['name'] = strtolower($headers[$key]['name']);
switch ($headers[$key]['name']) {
@@ -273,7 +274,7 @@ class Mail_mimeDecode extends PEAR
}
if (isset($content_type['other'])) {
while (list($p_name, $p_value) = each($content_type['other'])) {
foreach($content_type['other'] as $p_name => $p_value) {
$return->ctype_parameters[$p_name] = $p_value;
}
}
@@ -283,7 +284,7 @@ class Mail_mimeDecode extends PEAR
$content_disposition = $this->_parseHeaderValue($headers[$key]['value']);
$return->disposition = $content_disposition['value'];
if (isset($content_disposition['other'])) {
while (list($p_name, $p_value) = each($content_disposition['other'])) {
foreach($content_disposition['other'] as $p_name => $p_value) {
$return->d_parameters[$p_name] = $p_value;
}
}
@@ -315,6 +316,7 @@ class Mail_mimeDecode extends PEAR
case 'multipart/alternative':
case 'multipart/related':
case 'multipart/mixed':
case 'application/vnd.wap.multipart.related':
if(!isset($content_type['other']['boundary'])){
$this->_error = 'No boundary found for ' . $content_type['value'] . ' part';
return false;
@@ -337,7 +339,7 @@ class Mail_mimeDecode extends PEAR
$encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
$return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding) : $body);
}
$obj = &new Mail_mimeDecode($body);
$obj = new Mail_mimeDecode($body);
$return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies,
'decode_bodies' => $this->_decode_bodies,
'decode_headers' => $this->_decode_headers));
@@ -417,6 +419,11 @@ class Mail_mimeDecode extends PEAR
if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $match)) {
return array($match[1], $match[2]);
}
// bug #17325 - empty bodies are allowed. - we just check that at least one line
// of headers exist..
if (count(explode("\n",$input))) {
return array($input, '');
}
$this->_error = 'Could not split header and body';
return false;
}
@@ -435,7 +442,12 @@ class Mail_mimeDecode extends PEAR
if ($input !== '') {
// Unfold the input
$input = preg_replace("/\r?\n/", "\r\n", $input);
//#7065 - wrapping.. with encoded stuff.. - probably not needed,
// wrapping space should only get removed if the trailing item on previous line is a
// encoded character
$input = preg_replace("/=\r\n(\t| )+/", '=', $input);
$input = preg_replace("/\r\n(\t| )+/", ' ', $input);
$headers = explode("\r\n", trim($input));
foreach ($headers as $value) {
@@ -446,7 +458,7 @@ class Mail_mimeDecode extends PEAR
$return[] = array(
'name' => $hdr_name,
'value' => $this->_decode_headers ? $this->_decodeHeader($hdr_value) : $hdr_value
'value' => $hdr_value
);
}
} else {
@@ -470,41 +482,161 @@ class Mail_mimeDecode extends PEAR
function _parseHeaderValue($input)
{
if (($pos = strpos($input, ';')) !== false) {
$return['value'] = trim(substr($input, 0, $pos));
$input = trim(substr($input, $pos+1));
if (strlen($input) > 0) {
// This splits on a semi-colon, if there's no preceeding backslash
// Now works with quoted values; had to glue the \; breaks in PHP
// the regex is already bordering on incomprehensible
$splitRegex = '/([^;\'"]*[\'"]([^\'"]*([^\'"]*)*)[\'"][^;\'"]*|([^;]+))(;|$)/';
preg_match_all($splitRegex, $input, $matches);
$parameters = array();
for ($i=0; $i<count($matches[0]); $i++) {
$param = $matches[0][$i];
while (substr($param, -2) == '\;') {
$param .= $matches[0][++$i];
}
$parameters[] = $param;
}
for ($i = 0; $i < count($parameters); $i++) {
$param_name = trim(substr($parameters[$i], 0, $pos = strpos($parameters[$i], '=')), "'\";\t\\ ");
$param_value = trim(str_replace('\;', ';', substr($parameters[$i], $pos + 1)), "'\";\t\\ ");
if (!empty($param_value[0]) && $param_value[0] == '"') {
$param_value = substr($param_value, 1, -1);
}
$return['other'][$param_name] = $param_value;
$return['other'][strtolower($param_name)] = $param_value;
}
}
} else {
if (($pos = strpos($input, ';')) === false) {
$input = $this->_decode_headers ? $this->_decodeHeader($input) : $input;
$return['value'] = trim($input);
return $return;
}
$value = substr($input, 0, $pos);
$value = $this->_decode_headers ? $this->_decodeHeader($value) : $value;
$return['value'] = trim($value);
$input = trim(substr($input, $pos+1));
if (!strlen($input) > 0) {
return $return;
}
// at this point input contains xxxx=".....";zzzz="...."
// since we are dealing with quoted strings, we need to handle this properly..
$i = 0;
$l = strlen($input);
$key = '';
$val = false; // our string - including quotes..
$q = false; // in quote..
$lq = ''; // last quote..
while ($i < $l) {
$c = $input[$i];
//var_dump(array('i'=>$i,'c'=>$c,'q'=>$q, 'lq'=>$lq, 'key'=>$key, 'val' =>$val));
$escaped = false;
if ($c == '\\') {
$i++;
if ($i == $l-1) { // end of string.
break;
}
$escaped = true;
$c = $input[$i];
}
// state - in key..
if ($val === false) {
if (!$escaped && $c == '=') {
$val = '';
$key = trim($key);
$i++;
continue;
}
if (!$escaped && $c == ';') {
if ($key) { // a key without a value..
$key= trim($key);
$return['other'][$key] = '';
$return['other'][strtolower($key)] = '';
}
$key = '';
}
$key .= $c;
$i++;
continue;
}
// state - in value.. (as $val is set..)
if ($q === false) {
// not in quote yet.
if ((!strlen($val) || $lq !== false) && $c == ' ' || $c == "\t") {
$i++;
continue; // skip leading spaces after '=' or after '"'
}
if (!$escaped && ($c == '"' || $c == "'")) {
// start quoted area..
$q = $c;
// in theory should not happen raw text in value part..
// but we will handle it as a merged part of the string..
$val = !strlen(trim($val)) ? '' : trim($val);
$i++;
continue;
}
// got end....
if (!$escaped && $c == ';') {
$val = trim($val);
$added = false;
if (preg_match('/\*[0-9]+$/', $key)) {
// this is the extended aaa*0=...;aaa*1=.... code
// it assumes the pieces arrive in order, and are valid...
$key = preg_replace('/\*[0-9]+$/', '', $key);
if (isset($return['other'][$key])) {
$return['other'][$key] .= $val;
if (strtolower($key) != $key) {
$return['other'][strtolower($key)] .= $val;
}
$added = true;
}
// continue and use standard setters..
}
if (!$added) {
$return['other'][$key] = $val;
$return['other'][strtolower($key)] = $val;
}
$val = false;
$key = '';
$lq = false;
$i++;
continue;
}
$val .= $c;
$i++;
continue;
}
// state - in quote..
if (!$escaped && $c == $q) { // potential exit state..
// end of quoted string..
$lq = $q;
$q = false;
$i++;
continue;
}
// normal char inside of quoted string..
$val.= $c;
$i++;
}
// do we have anything left..
if (strlen(trim($key)) || $val !== false) {
$val = trim($val);
$added = false;
if ($val !== false && preg_match('/\*[0-9]+$/', $key)) {
// no dupes due to our crazy regexp.
$key = preg_replace('/\*[0-9]+$/', '', $key);
if (isset($return['other'][$key])) {
$return['other'][$key] .= $val;
if (strtolower($key) != $key) {
$return['other'][strtolower($key)] .= $val;
}
$added = true;
}
// continue and use standard setters..
}
if (!$added) {
$return['other'][$key] = $val;
$return['other'][strtolower($key)] = $val;
}
}
// decode values.
foreach($return['other'] as $key =>$val) {
$return['other'][$key] = $this->_decode_headers ? $this->_decodeHeader($val) : $val;
}
//print_r($return);
return $return;
}
@@ -526,13 +658,19 @@ class Mail_mimeDecode extends PEAR
if ($boundary == $bs_check) {
$boundary = $bs_possible;
}
$tmp = preg_split("/--".preg_quote($boundary, '/')."((?=\s)|--)/", $input);
$tmp = explode('--' . $boundary, $input);
for ($i = 1; $i < count($tmp) - 1; $i++) {
$parts[] = $tmp[$i];
$len = count($tmp) -1;
for ($i = 1; $i < $len; $i++) {
if (strlen(trim($tmp[$i]))) {
$parts[] = $tmp[$i];
}
}
// add the last part on if it does not end with the 'closing indicator'
if (!empty($tmp[$len]) && strlen(trim($tmp[$len])) && $tmp[$len][0] != '-') {
$parts[] = $tmp[$len];
}
return $parts;
}
+187 -107
View File
@@ -48,7 +48,7 @@
* @author Aleksander Machniak <alec@php.net>
* @copyright 2003-2006 PEAR <pear-group@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version CVS: $Id: mimePart.php 296266 2010-03-16 10:21:59Z alec $
* @version CVS: $Id: mimePart.php 8229 2011-03-31 10:17:44Z ips_terabyte $
* @link http://pear.php.net/package/Mail_mime
*/
@@ -141,17 +141,19 @@ class Mail_mimePart
* content_type - The content type for this part eg multipart/mixed
* encoding - The encoding to use, 7bit, 8bit,
* base64, or quoted-printable
* charset - Content character set
* cid - Content ID to apply
* disposition - Content disposition, inline or attachment
* dfilename - Filename parameter for content disposition
* description - Content description
* charset - Character set to use
* name_encoding - Encoding for attachment name (Content-Type)
* name_encoding - Encoding of the attachment name (Content-Type)
* By default filenames are encoded using RFC2231
* Here you can set RFC2047 encoding (quoted-printable
* or base64) instead
* filename_encoding - Encoding for attachment filename (Content-Disposition)
* filename_encoding - Encoding of the attachment filename (Content-Disposition)
* See 'name_encoding'
* headers_charset - Charset of the headers e.g. filename, description.
* If not set, 'charset' will be used
* eol - End of line sequence. Default: "\r\n"
* body_file - Location of file with part's body (instead of $body)
*
@@ -165,14 +167,8 @@ class Mail_mimePart
$this->_eol = MAIL_MIMEPART_CRLF;
}
$c_type = array();
$c_disp = array();
foreach ($params as $key => $value) {
switch ($key) {
case 'content_type':
$c_type['type'] = $value;
break;
case 'encoding':
$this->_encoding = $value;
$headers['Content-Transfer-Encoding'] = $value;
@@ -182,29 +178,6 @@ class Mail_mimePart
$headers['Content-ID'] = '<' . $value . '>';
break;
case 'disposition':
$c_disp['disp'] = $value;
break;
case 'dfilename':
$c_disp['filename'] = $value;
$c_type['name'] = $value;
break;
case 'description':
$headers['Content-Description'] = $value;
break;
case 'charset':
$c_type['charset'] = $value;
$c_disp['charset'] = $value;
break;
case 'language':
$c_type['language'] = $value;
$c_disp['language'] = $value;
break;
case 'location':
$headers['Content-Location'] = $value;
break;
@@ -215,50 +188,59 @@ class Mail_mimePart
}
}
// Default content-type
if (empty($params['content_type'])) {
$params['content_type'] = 'text/plain';
}
// Content-Type
if (isset($c_type['type'])) {
$headers['Content-Type'] = $c_type['type'];
if (isset($c_type['name'])) {
$headers['Content-Type'] .= ';' . $this->_eol;
$headers['Content-Type'] .= $this->_buildHeaderParam(
'name', $c_type['name'],
isset($c_type['charset']) ? $c_type['charset'] : 'US-ASCII',
isset($c_type['language']) ? $c_type['language'] : null,
isset($params['name_encoding']) ? $params['name_encoding'] : null
);
$headers['Content-Type'] = $params['content_type'];
if (!empty($params['charset'])) {
$charset = "charset={$params['charset']}";
// place charset parameter in the same line, if possible
if ((strlen($headers['Content-Type']) + strlen($charset) + 16) <= 76) {
$headers['Content-Type'] .= '; ';
} else {
$headers['Content-Type'] .= ';' . $this->_eol . ' ';
}
if (isset($c_type['charset'])) {
$headers['Content-Type']
.= ';' . $this->_eol . " charset={$c_type['charset']}";
$headers['Content-Type'] .= $charset;
// Default headers charset
if (!isset($params['headers_charset'])) {
$params['headers_charset'] = $params['charset'];
}
}
// Content-Disposition
if (isset($c_disp['disp'])) {
$headers['Content-Disposition'] = $c_disp['disp'];
if (isset($c_disp['filename'])) {
$headers['Content-Disposition'] .= ';' . $this->_eol;
$headers['Content-Disposition'] .= $this->_buildHeaderParam(
'filename', $c_disp['filename'],
isset($c_disp['charset']) ? $c_disp['charset'] : 'US-ASCII',
isset($c_disp['language']) ? $c_disp['language'] : null,
isset($params['filename_encoding']) ? $params['filename_encoding'] : null
);
}
}
if (!empty($headers['Content-Description'])) {
$headers['Content-Description'] = $this->encodeHeader(
'Content-Description', $headers['Content-Description'],
isset($c_type['charset']) ? $c_type['charset'] : 'US-ASCII',
isset($params['name_encoding']) ? $params['name_encoding'] : 'quoted-printable',
$this->_eol
if (!empty($params['filename'])) {
$headers['Content-Type'] .= ';' . $this->_eol;
$headers['Content-Type'] .= $this->_buildHeaderParam(
'name', $params['filename'],
!empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII',
!empty($params['language']) ? $params['language'] : null,
!empty($params['name_encoding']) ? $params['name_encoding'] : null
);
}
// Default content-type
if (!isset($headers['Content-Type'])) {
$headers['Content-Type'] = 'text/plain';
// Content-Disposition
if (!empty($params['disposition'])) {
$headers['Content-Disposition'] = $params['disposition'];
if (!empty($params['filename'])) {
$headers['Content-Disposition'] .= ';' . $this->_eol;
$headers['Content-Disposition'] .= $this->_buildHeaderParam(
'filename', $params['filename'],
!empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII',
!empty($params['language']) ? $params['language'] : null,
!empty($params['filename_encoding']) ? $params['filename_encoding'] : null
);
}
}
if (!empty($params['description'])) {
$headers['Content-Description'] = $this->encodeHeader(
'Content-Description', $params['description'],
!empty($params['headers_charset']) ? $params['headers_charset'] : 'US-ASCII',
!empty($params['name_encoding']) ? $params['name_encoding'] : 'quoted-printable',
$this->_eol
);
}
// Default encoding
@@ -960,33 +942,39 @@ class Mail_mimePart
*/
function encodeHeaderValue($value, $charset, $encoding, $prefix_len=0, $eol="\r\n")
{
if ($encoding == 'base64') {
// #17311: Use multibyte aware method (requires mbstring extension)
if ($result = Mail_mimePart::encodeMB($value, $charset, $encoding, $prefix_len, $eol)) {
return $result;
}
// Generate the header using the specified params and dynamicly
// determine the maximum length of such strings.
// 75 is the value specified in the RFC.
$encoding = $encoding == 'base64' ? 'B' : 'Q';
$prefix = '=?' . $charset . '?' . $encoding .'?';
$suffix = '?=';
$maxLength = 75 - strlen($prefix . $suffix);
$maxLength1stLine = $maxLength - $prefix_len;
if ($encoding == 'B') {
// Base64 encode the entire string
$value = base64_encode($value);
// Generate the header using the specified params and dynamicly
// determine the maximum length of such strings.
// 75 is the value specified in the RFC.
$prefix = '=?' . $charset . '?B?';
$suffix = '?=';
$maxLength = 75 - strlen($prefix . $suffix) - 2;
$maxLength1stLine = $maxLength - $prefix_len;
// We can cut base4 every 4 characters, so the real max
// We can cut base64 every 4 characters, so the real max
// we can get must be rounded down.
$maxLength = $maxLength - ($maxLength % 4);
$maxLength1stLine = $maxLength1stLine - ($maxLength1stLine % 4);
$cutpoint = $maxLength1stLine;
$value_out = $value;
$output = '';
while ($value_out) {
while ($value) {
// Split translated string at every $maxLength
$part = substr($value_out, 0, $cutpoint);
$value_out = substr($value_out, $cutpoint);
$part = substr($value, 0, $cutpoint);
$value = substr($value, $cutpoint);
$cutpoint = $maxLength;
// RFC 2047 specifies that any split header should
// be seperated by a CRLF SPACE.
// be seperated by a CRLF SPACE.
if ($output) {
$output .= $eol . ' ';
}
@@ -997,30 +985,19 @@ class Mail_mimePart
// quoted-printable encoding has been selected
$value = Mail_mimePart::encodeQP($value);
// Generate the header using the specified params and dynamicly
// determine the maximum length of such strings.
// 75 is the value specified in the RFC.
$prefix = '=?' . $charset . '?Q?';
$suffix = '?=';
$maxLength = 75 - strlen($prefix . $suffix) - 3;
$maxLength1stLine = $maxLength - $prefix_len;
$maxLength = $maxLength - 1;
// This regexp will break QP-encoded text at every $maxLength
// but will not break any encoded letters.
$reg1st = "|(.{0,$maxLength1stLine}[^\=][^\=])|";
$reg2nd = "|(.{0,$maxLength}[^\=][^\=])|";
$value_out = $value;
$realMax = $maxLength1stLine + strlen($prefix . $suffix);
if (strlen($value_out) >= $realMax) {
if (strlen($value) > $maxLength1stLine) {
// Begin with the regexp for the first line.
$reg = $reg1st;
$output = '';
while ($value_out) {
while ($value) {
// Split translated string at every $maxLength
// But make sure not to break any translated chars.
$found = preg_match($reg, $value_out, $matches);
$found = preg_match($reg, $value, $matches);
// After this first line, we need to use a different
// regexp for the first line.
@@ -1032,24 +1009,23 @@ class Mail_mimePart
if ($found) {
$part = $matches[0];
$len = strlen($matches[0]);
$value_out = substr($value_out, $len);
$value = substr($value, $len);
} else {
$part = $value_out;
$value_out = "";
$part = $value;
$value = '';
}
// RFC 2047 specifies that any split header should
// RFC 2047 specifies that any split header should
// be seperated by a CRLF SPACE
if ($output) {
$output .= $eol . ' ';
}
$output .= $prefix . $part . $suffix;
}
$value_out = $output;
$value = $output;
} else {
$value_out = $prefix . $value_out . $suffix;
$value = $prefix . $value . $suffix;
}
$value = $value_out;
}
return $value;
@@ -1067,7 +1043,7 @@ class Mail_mimePart
function encodeQP($str)
{
// Bug #17226 RFC 2047 restricts some characters
// if the word is inside a phrase, permit chars are only:
// if the word is inside a phrase, permitted chars are only:
// ASCII letters, decimal digits, "!", "*", "+", "-", "/", "=", and "_"
// "=", "_", "?" must be encoded
@@ -1079,6 +1055,110 @@ class Mail_mimePart
return str_replace(' ', '_', $str);
}
/**
* Encodes the given string using base64 or quoted-printable.
* This method makes sure that encoded-word represents an integral
* number of characters as per RFC2047.
*
* @param string $str String to encode
* @param string $charset Character set name
* @param string $encoding Encoding name (base64 or quoted-printable)
* @param int $prefix_len Prefix length. Default: 0
* @param string $eol End-of-line sequence. Default: "\r\n"
*
* @return string Encoded string
* @access public
* @since 1.8.0
*/
function encodeMB($str, $charset, $encoding, $prefix_len=0, $eol="\r\n")
{
if (!function_exists('mb_substr') || !function_exists('mb_strlen')) {
return;
}
$encoding = $encoding == 'base64' ? 'B' : 'Q';
// 75 is the value specified in the RFC
$prefix = '=?' . $charset . '?'.$encoding.'?';
$suffix = '?=';
$maxLength = 75 - strlen($prefix . $suffix);
// A multi-octet character may not be split across adjacent encoded-words
// So, we'll loop over each character
// mb_stlen() with wrong charset will generate a warning here and return null
$length = mb_strlen($str, $charset);
$result = '';
$line_length = $prefix_len;
if ($encoding == 'B') {
// base64
$start = 0;
$prev = '';
for ($i=1; $i<=$length; $i++) {
// See #17311
$chunk = mb_substr($str, $start, $i-$start, $charset);
$chunk = base64_encode($chunk);
$chunk_len = strlen($chunk);
if ($line_length + $chunk_len == $maxLength || $i == $length) {
if ($result) {
$result .= "\n";
}
$result .= $chunk;
$line_length = 0;
$start = $i;
} else if ($line_length + $chunk_len > $maxLength) {
if ($result) {
$result .= "\n";
}
if ($prev) {
$result .= $prev;
}
$line_length = 0;
$start = $i - 1;
} else {
$prev = $chunk;
}
}
} else {
// quoted-printable
// see encodeQP()
$regexp = '/([\x22-\x29\x2C\x2E\x3A-\x40\x5B-\x60\x7B-\x7E\x80-\xFF])/';
for ($i=0; $i<=$length; $i++) {
$char = mb_substr($str, $i, 1, $charset);
// RFC recommends underline (instead of =20) in place of the space
// that's one of the reasons why we're not using iconv_mime_encode()
if ($char == ' ') {
$char = '_';
$char_len = 1;
} else {
$char = preg_replace_callback(
$regexp, array('Mail_mimePart', '_qpReplaceCallback'), $char
);
$char_len = strlen($char);
}
if ($line_length + $char_len > $maxLength) {
if ($result) {
$result .= "\n";
}
$line_length = 0;
}
$result .= $char;
$line_length += $char_len;
}
}
if ($result) {
$result = $prefix
.str_replace("\n", $suffix.$eol.' '.$prefix, $result).$suffix;
}
return $result;
}
/**
* Callback function to replace extended characters (\x80-xFF) with their
* ASCII values (RFC2047: quoted-printable)
+1 -1
View File
@@ -49,7 +49,7 @@ class Text_Diff {
$engine = basename($engine);
}
require_once 'Text/Diff/Engine/' . $engine . '.php';
require_once 'Text/Diff/Engine/' . $engine . '.php';/*noLibHook*/
$class = 'Text_Diff_Engine_' . $engine;
$diff_engine = new $class();
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -15,7 +15,7 @@
*/
/** Text_Diff_Renderer */
require_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer.php';/*noLibHook*/
/**
* @package Text_Diff
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -14,7 +14,7 @@
*/
/** Text_Diff_Renderer */
require_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer.php';/*noLibHook*/
/**
* "Inline" diff renderer.
@@ -16,7 +16,7 @@
*/
/** Text_Diff_Renderer */
require_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer.php';/*noLibHook*/
/**
* @package Text_Diff
@@ -14,7 +14,7 @@
*/
/** Text_Diff_Renderer */
require_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer.php';/*noLibHook*/
/**
* "Inline" diff renderer.
@@ -16,7 +16,7 @@
*/
/** Text_Diff_Renderer */
require_once 'Text/Diff/Renderer.php';
require_once 'Text/Diff/Renderer.php';/*noLibHook*/
/**
* @package Text_Diff
@@ -14,7 +14,7 @@
*/
/** Text_Diff */
require_once 'Text/Diff.php';
require_once 'Text/Diff.php';/*noLibHook*/
/**
* A class for computing three way diffs.
+1 -1
View File
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
+3 -3
View File
@@ -14,7 +14,7 @@
*/
/** Text_Diff */
require_once 'Text/Diff.php';
require_once 'Text/Diff.php';/*noLibHook*/
/**
* A class for computing three way diffs.
@@ -41,10 +41,10 @@ class Text_Diff3 extends Text_Diff {
function Text_Diff3($orig, $final1, $final2)
{
if (extension_loaded('xdiff')) {
require_once 'Text/Diff/Engine/xdiff.php';
require_once 'Text/Diff/Engine/xdiff.php';/*noLibHook*/
$engine = new Text_Diff_Engine_xdiff();
} else {
require_once 'Text/Diff/Engine/native.php';
require_once 'Text/Diff/Engine/native.php';/*noLibHook*/
$engine = new Text_Diff_Engine_native();
}
+1 -1
View File
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
+1 -1
View File
@@ -5,6 +5,6 @@
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>