Skip to content

Commit

Permalink
Update RegexRepository.php to use the PCRE modifier 'S' (#44)
Browse files Browse the repository at this point in the history
Increases sanitization performance in regex repository.  
More information: https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
  • Loading branch information
Magentron committed Nov 6, 2023
1 parent 745ea65 commit 4231686
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Repositories/RegexRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public function __construct(

public static function checkAndSanitize(string $regex, string $replace, string $content, int &$hits = 0): string
{
return preg_replace("~$regex~i", $replace, $content, -1, $hits);
return preg_replace("~$regex~Si", $replace, $content, -1, $hits);
}

public static function check(string $regex, string $content): int
{
return preg_match_all("~$regex~i", $content);
return preg_match_all("~$regex~Si", $content);
}

public function getRegexCollection(): Collection
Expand Down

0 comments on commit 4231686

Please sign in to comment.