Skip to content
This repository
Browse code

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
Joel Perras authored
4  cake/libs/controller/components/email.php
@@ -632,7 +632,9 @@ function __formatAddress($string, $smtp = false) {
632 632
  * @access private
633 633
  */
634 634
 	function __strip($value, $message = false) {
635  
-		$search = '%0a|%0d|Content-(?:Type|Transfer-Encoding)\:|charset\=|mime-version\:|multipart/mixed|(?:to|b?cc)\:.*';
  635
+		$search  = '%0a|%0d|Content-(?:Type|Transfer-Encoding)\:';
  636
+		$search .= '|charset\=|mime-version\:|multipart/mixed|(?:[^a-z]to|b?cc)\:.*';
  637
+
636 638
 		if ($message !== true) {
637 639
 			$search .= '|\r|\n';
638 640
 		}
23  cake/tests/cases/libs/controller/components/email.test.php
@@ -104,6 +104,15 @@ function getBoundary() {
104 104
 	function getMessage() {
105 105
 		return $this->__message;
106 106
 	}
  107
+/**
  108
+ * Convenience method for testing.
  109
+ *
  110
+ * @access public
  111
+ * @return string
  112
+ */
  113
+	function strip($content, $message = false) {
  114
+		return parent::__strip($content, $message);
  115
+	}
107 116
 }
108 117
 /**
109 118
  * EmailTestController class
@@ -499,9 +508,21 @@ function testContentStripping() {
499 508
 		$content = "Previous content\n--alt-\nContent-TypeContent-Type:: text/html; charsetcharset==utf-8\nContent-Transfer-Encoding: 7bit";
500 509
 		$content .= "\n\n<p>My own html content</p>";
501 510
 
502  
-		$result = $this->Controller->EmailTest->__strip($content, true);
  511
+		$result = $this->Controller->EmailTest->strip($content, true);
503 512
 		$expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>";
504 513
 		$this->assertEqual($result, $expected);
  514
+
  515
+		$content = '<p>Some HTML content with an <a href="mailto:test@example.com">email link</a>';
  516
+		$result  = $this->Controller->EmailTest->strip($content, true);
  517
+		$expected = $content;
  518
+		$this->assertEqual($result, $expected);
  519
+
  520
+		$content  = '<p>Some HTML content with an ';
  521
+		$content .= '<a href="mailto:test@example.com,test2@example.com">email link</a>';
  522
+		$result  = $this->Controller->EmailTest->strip($content, true);
  523
+		$expected = $content;
  524
+		$this->assertEqual($result, $expected);
  525
+
505 526
 	}
506 527
 /**
507 528
  * testMultibyte method

0 notes on commit a6d3193

Please sign in to comment.
Something went wrong with that request. Please try again.