Skip to content

Commit

Permalink
Fixed the regular expression
Browse files Browse the repository at this point in the history
  • Loading branch information
demis-palma committed Jul 29, 2016
1 parent 9d7f941 commit 883921e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/content/emailcloak/emailcloak.php
Expand Up @@ -479,8 +479,10 @@ protected function _cloak(&$text, &$params)
$text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
}

// Search for plain text email@example.org
$pattern = '~' . $searchEmail . '([^a-z0-9]|$)~i';
// Search for plain text email addresses, such as email@example.org but not within HTML tags:
// <img src="..." title="email@example.org"> or <input type="text" placeholder="email@example.org">
// The negative lookahead '(?![^<]*>)' is used to exclude this kind occurrences
$pattern = '~(?![^<>]*>)' . $searchEmail . '~i';

while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
Expand Down

0 comments on commit 883921e

Please sign in to comment.