Updated EmailComponent::__strip regex for mailto: links. Fixes #6464.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8211 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
jperras 2009-07-02 02:58:43 +00:00
parent c30dd48e2a
commit a6d3193a6d
2 changed files with 25 additions and 2 deletions

View file

@ -632,7 +632,9 @@ class EmailComponent extends Object{
* @access private * @access private
*/ */
function __strip($value, $message = false) { function __strip($value, $message = false) {
$search = '%0a|%0d|Content-(?:Type|Transfer-Encoding)\:|charset\=|mime-version\:|multipart/mixed|(?:to|b?cc)\:.*'; $search = '%0a|%0d|Content-(?:Type|Transfer-Encoding)\:';
$search .= '|charset\=|mime-version\:|multipart/mixed|(?:[^a-z]to|b?cc)\:.*';
if ($message !== true) { if ($message !== true) {
$search .= '|\r|\n'; $search .= '|\r|\n';
} }

View file

@ -104,6 +104,15 @@ class EmailTestComponent extends EmailComponent {
function getMessage() { function getMessage() {
return $this->__message; return $this->__message;
} }
/**
* Convenience method for testing.
*
* @access public
* @return string
*/
function strip($content, $message = false) {
return parent::__strip($content, $message);
}
} }
/** /**
* EmailTestController class * EmailTestController class
@ -499,9 +508,21 @@ TEXTBLOC;
$content = "Previous content\n--alt-\nContent-TypeContent-Type:: text/html; charsetcharset==utf-8\nContent-Transfer-Encoding: 7bit"; $content = "Previous content\n--alt-\nContent-TypeContent-Type:: text/html; charsetcharset==utf-8\nContent-Transfer-Encoding: 7bit";
$content .= "\n\n<p>My own html content</p>"; $content .= "\n\n<p>My own html content</p>";
$result = $this->Controller->EmailTest->__strip($content, true); $result = $this->Controller->EmailTest->strip($content, true);
$expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>"; $expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>";
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$content = '<p>Some HTML content with an <a href="mailto:test@example.com">email link</a>';
$result = $this->Controller->EmailTest->strip($content, true);
$expected = $content;
$this->assertEqual($result, $expected);
$content = '<p>Some HTML content with an ';
$content .= '<a href="mailto:test@example.com,test2@example.com">email link</a>';
$result = $this->Controller->EmailTest->strip($content, true);
$expected = $content;
$this->assertEqual($result, $expected);
} }
/** /**
* testMultibyte method * testMultibyte method