Skip to content

Commit

Permalink
Speed up regex in emailcloak plugin (#20956)
Browse files Browse the repository at this point in the history
* Speed up regex in emailcloak plugin

* Fix comment
  • Loading branch information
csthomas authored and Michael Babker committed Jul 21, 2018
1 parent 8655c2c commit d6e33a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/content/emailcloak/emailcloak.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ protected function _cloak(&$text, &$params)
/*
* 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 of occurrences
* The '<[^<]*>(*SKIP)(*F)|' trick is used to exclude this kind of occurrences
*/
$pattern = '~(?![^<>]*>)' . $searchEmail . '~i';
$pattern = '~<[^<]*>(*SKIP)(*F)|' . $searchEmail . '~i';

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

0 comments on commit d6e33a4

Please sign in to comment.