mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-09-28 04:59:04 +00:00
simplify word boundary check
This commit is contained in:
parent
a2bb820771
commit
ce6ca7a939
@ -257,14 +257,16 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
$regex = preg_quote($singleTest, '/');
|
$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]))
|
if (ctype_alpha($singleTest[0]))
|
||||||
{
|
{
|
||||||
$regex = '(?<=\W|^)' . $regex;
|
$regex = '\b' . $regex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctype_alpha($singleTest[strlen($singleTest) - 1]))
|
if (ctype_alpha($singleTest[strlen($singleTest) - 1]))
|
||||||
{
|
{
|
||||||
$regex .= '(?=\W|$)';
|
$regex .= '\b';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/' . $regex . '/i', $line))
|
if (preg_match('/' . $regex . '/i', $line))
|
||||||
|
Loading…
Reference in New Issue
Block a user