31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-06-22 06:15:06 +00:00

simplify word boundary check

This commit is contained in:
Denis Ryabov 2021-03-10 13:13:30 +03:00
parent a2bb820771
commit ce6ca7a939

View File

@ -257,14 +257,16 @@ class JedcheckerRulesFramework extends JEDcheckerRule
{
$regex = preg_quote($singleTest, '/');
// Add word boundary check for rules staring/ending with a letter (to avoid false-positives because of partial match)
if (ctype_alpha($singleTest[0]))
{
$regex = '(?<=\W|^)' . $regex;
$regex = '\b' . $regex;
}
if (ctype_alpha($singleTest[strlen($singleTest) - 1]))
{
$regex .= '(?=\W|$)';
$regex .= '\b';
}
if (preg_match('/' . $regex . '/i', $line))