$address = trim($this->registry->unsanitize($address));
$name = $this->_fetch_first_line($name);
$name = trim($this->registry->unsanitize($name));
+ $name = $this->_encodeHeaderValue($name);
$tostring = ($name == null ? $address : "\"$name\" <$address>");
// sanitize the from field
// sanitize the from name
$this->fromname = $this->_fetch_first_line($this->fromname);
$this->fromname = ($this->fromname == '' ? $this->from : trim($this->registry->unsanitize($this->fromname)));
+ $this->fromname = $this->_encodeHeaderValue($this->fromname);
// sanitize the subject
$this->subject = $this->_fetch_first_line($this->subject);
$this->subject = trim($this->registry->unsanitize($this->subject));
+ $this->subject = $this->_encodeHeaderValue($this->subject);
// sanitize the body
$this->bodytext = $this->registry->modules['functions']->convert_line_breaks($this->bodytext, $this->delim);
$broken = explode("\n", $string);
return $broken[0];
}
+
+ // ###################################################################
+ /**
+ * Encodes a header value (to name, fron name, subject, etc.) according
+ * to RFC 2047
+ *
+ * @param string The text to encode
+ *
+ * @return string Encoded text
+ */
+ function _encodeHeaderValue($text)
+ {
+ $enc = '';
+
+ for ($i = 0; $i < strlen($text); $i++)
+ {
+ $char = ord($text[$i]);
+ // allowed characters: a-zA-Z0-9_\+\-\*_=
+ if (($char >= 65 AND $char <= 90) OR ($char >= 97 AND $char <= 122) OR ($char >= 48 AND $char <= 57) OR $char == 33 OR $char == 42 OR $char == 43 OR $char == 45 OR $char == 47 OR $char == 61)
+ {
+ $enc .= $text[$i];
+ }
+ else
+ {
+ // this is a non-ASCII character, so encode it
+ $enc .= '=' . strtoupper(dechex($char));
+ }
+ }
+
+ return '=?' . $this->charset . '?q?' . $enc . '?=';
+ }
}
/*=====================================================================*\