diff --git a/plugins/content/emailcloak/emailcloak.php b/plugins/content/emailcloak/emailcloak.php index 59279d46a29fb..e4f4b31daafef 100644 --- a/plugins/content/emailcloak/emailcloak.php +++ b/plugins/content/emailcloak/emailcloak.php @@ -377,13 +377,13 @@ protected function _cloak(&$text, &$params) while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) { $mail = $regs[2][0] . $regs[3][0]; - $mailText = $regs[4][0] . $regs[5][0] . $regs[6][0] . $regs[7][0]; + $mailText = $regs[5][0] . $regs[6][0] . $regs[7][0]; // Check to see if mail text is different from mail addy $replacement = JHtml::_('email.cloak', $mail, $mode, $mailText); // Ensure that attributes is not stripped out by email cloaking - $replacement = html_entity_decode($this->_addAttributesToEmail($replacement, $regs[1][0], $regs[3][0])); + $replacement = html_entity_decode($this->_addAttributesToEmail($replacement, $regs[1][0], $regs[4][0])); // Replace the found address with the js cloaked email $text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0])); @@ -398,12 +398,12 @@ protected function _cloak(&$text, &$params) while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) { $mail = $regs[2][0] . $regs[3][0]; - $mailText = $regs[4][0] . $regs[5][0] . addslashes($regs[6][0]) . $regs[7][0]; + $mailText = $regs[5][0] . addslashes($regs[6][0]) . $regs[7][0]; $replacement = JHtml::_('email.cloak', $mail, $mode, $mailText, 0); // Ensure that attributes is not stripped out by email cloaking - $replacement = html_entity_decode($this->_addAttributesToEmail($replacement, $regs[1][0], $regs[3][0])); + $replacement = html_entity_decode($this->_addAttributesToEmail($replacement, $regs[1][0], $regs[4][0])); // Replace the found address with the js cloaked email $text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0])); diff --git a/tests/unit/suites/plugins/content/emailcloak/PlgContentEmailcloakTest.php b/tests/unit/suites/plugins/content/emailcloak/PlgContentEmailcloakTest.php index 8e5e0693d408b..fac9fd156b694 100644 --- a/tests/unit/suites/plugins/content/emailcloak/PlgContentEmailcloakTest.php +++ b/tests/unit/suites/plugins/content/emailcloak/PlgContentEmailcloakTest.php @@ -70,8 +70,7 @@ public function setup() public function dataTestOnContentPrepare() { return array( - - # 0 + // 0 array( // This first row is the input, this is what would be in the article 'this should not be parsed as it has no (at) sign in it - see what I did there? ;)', @@ -90,28 +89,22 @@ public function dataTestOnContentPrepare() ), - # ? - see: https://github.com/joomla/joomla-cms/pull/11378#issuecomment-237829598 - /** - * This is failing at the moment so Im excluding it while the above PR #11378 is worked on - * and while this unit test suite is being improved - but this test highlights the fact we need these tests! - * - * array( - * 'email', - * "email", - * " - * JLIB_HTML_CLOAKING - * " - * ),*/ - - - # 1 + // 1 + array( + 'email', + "email", + "JLIB_HTML_CLOAKING + " + ), + + // 2 array( 'anytext', @@ -128,7 +121,7 @@ public function dataTestOnContentPrepare() " ), - # 2 + // 3 array( '

Joe_fontsize8

', @@ -146,11 +139,11 @@ public function dataTestOnContentPrepare() " ), - # 3 + // 4 array( '

Joe_subject_ fontsize13

', - 'Joe_subject_ fontsize13', + 'Joe_subject_ fontsize13', "

JLIB_HTML_CLOAKING

" ), + // 5 + array( + '

something

', -// [ -// '

joe@nowhere14.com

', -// 'Joe_fontsize8' -// ], -// [ -// '

joe@nowhere16.com

', -// 'Joe_fontsize8' -// ], -// [ -// '

something

', -// 'Joe_fontsize8' -// ], -// [ -// '

mymail@mysite.com

', -// 'Joe_fontsize8' -// ], -// [ -// '

joe@nowhere.com

', -// 'Joe_fontsize8' -// ], -// [ -// '

mymail@mysite.com

', -// 'Joe_fontsize8' -// ], -// [ -// '

Joe Nobody

', -// 'Joe_fontsize8' -// ], -// [ -// '

strong and span

', -// 'Joe_fontsize8' -// ], -// [ -// 'email@amail.com', -// 'Joe_fontsize8' -// ], -// [ -// 'email@example.org', -// 'email@example.org' -// ], -// [ -// 'email@example.org', -// 'email@example.org' -// ], + 'something', + + " +

JLIB_HTML_CLOAKING

+ " + ), + + // 6 + // TODO: I would expect that the email in the strong tag should ALSO be converted? + array( + '

mymail@mysite.com

', + + 'mymail@mysite.com', + + " +

JLIB_HTML_CLOAKING

+ " + ), + + // 7 + array( + '

mymail@mysite.com

', + + 'mymail@mysite.com', + + " +

JLIB_HTML_CLOAKING

+ " + ), + + // 8 + array( + '

Joe Nobody

', + + 'Joe Nobody', + + " +

JLIB_HTML_CLOAKING

+ " + ), + + // 9 + // TODO: I would expect that the email in the strong tag should ALSO be converted? + array( + '

joe@nowhere.com

', + + 'joe@nowhere.com', + + " +

JLIB_HTML_CLOAKING

+ " + ), + + // 10 + array( + '

joe@nowhere.com

', + + 'joe@nowhere.com', + + " +

JLIB_HTML_CLOAKING

+ " + ), + + // 11 + array( + 'email@example.org', + + "email@example.org", + + "JLIB_HTML_CLOAKING + " + ), + + // 12 - similar to test 9 but with the addition of classes + // TODO: I would expect that the email in the strong tag should ALSO be converted? + array( + '

joe@nowhere.com

', + + 'joe@nowhere.com', + + " +

JLIB_HTML_CLOAKING

+ " + ), + + // 13 - Similar to test 4 but with the addition of classes + array( + '

Joe_subject_ fontsize13

', + + 'Joe_subject_ fontsize13', + + " +

JLIB_HTML_CLOAKING

+ " + ), + + // 14 + array( + 'toto@toto.com', + "toto@toto.com", + "JLIB_HTML_CLOAKING + " + ), + + // 15 + array( + 'Click Here', + "Click Here", + "JLIB_HTML_CLOAKING + " + ), ); }