[Plugin: SEO Auto Linker] Regex pattern incorrect
-
Problem: The plugin won’t auto-link keywords that have question marks or other punctuation in them (specifically, at the beginning or end of the keyword). This may also cause problems with keywords containing non-ASCII (i.e. Unicode) characters.
Cause: get_kw_regex() in inc/front.php uses an incorrect pattern. The pattern used is:
return sprintf('/(\b)(%s)(\b)/ui', implode('|', $keywords));
\b is a word boundary where a word character and a non-word character are adjacent, but “word” characters only include [A-Za-z0-9_]. So a keyword ending in “?” will never create a word boundary, because it’s not a word character.
Solution: Instead of using word boundaries, just use non-word characters:
return sprintf('/(\W)(%s)(\W)/ui', implode('|', $keywords));
I imagine this could be the cause of the reported Unicode problems too, since a keyword beginning or ending with a Unicode character would not create a word boundary either.
https://www.ads-software.com/extend/plugins/seo-auto-linker/
- The topic ‘[Plugin: SEO Auto Linker] Regex pattern incorrect’ is closed to new replies.