Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit a6d3193a6dcff4450b1555c89405bdcc3575576a 1 parent c30dd48
@jperras jperras authored
View
4 cake/libs/controller/components/email.php
@@ -632,7 +632,9 @@ function __formatAddress($string, $smtp = false) {
* @access private
*/
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) {
$search .= '|\r|\n';
}
View
23 cake/tests/cases/libs/controller/components/email.test.php
@@ -104,6 +104,15 @@ function getBoundary() {
function getMessage() {
return $this->__message;
}
+/**
+ * Convenience method for testing.
+ *
+ * @access public
+ * @return string
+ */
+ function strip($content, $message = false) {
+ return parent::__strip($content, $message);
+ }
}
/**
* EmailTestController class
@@ -499,9 +508,21 @@ function testContentStripping() {
$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>";
- $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>";
$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
Please sign in to comment.
Something went wrong with that request. Please try again.