How a naive regex silently logged plugin versions as WordPress core versions
A developer discovered that scraping WordPress core version numbers from the update-core.php admin page could silently return wrong values, because the page also displays version numbers for pending plugin updates. A simple regex matching the first version-shaped number on the page picked up a plugin's version string, such as 1.7.11, instead of the actual WordPress core version. The bug produced no errors, making it hard to detect until someone noticed the reported version had never existed in WordPress core's release history. The recommended fix involves a three-layer approach: prioritising specific DOM selectors, falling back to keyword-anchored regex, and validating that the extracted major version number falls within the known WordPress core range of 4 to 9. The case highlights a broader principle that a successful regex match does not guarantee the matched value is semantically correct.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in