opkg_manager: fix invalid match with -foo$ "regex"

Origin commit data
------------------
Commit: b9a5a30c52
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2016-01-01 (Fri, 01 Jan 2016)
This commit is contained in:
Stefan Seyfried
2016-01-01 23:18:19 +01:00
parent 8b110e80bb
commit 2351c9922c

View File

@@ -369,13 +369,14 @@ bool COPKGManager::badpackage(std::string &s)
bool res = false;
/* poor man's regex :-) only supported are "^" and "$" */
if (p.substr(patlen, 1) == "$") { /* match at end */
if (s.rfind(p.substr(0, patlen)) == (s.length() - patlen))
size_t pos = s.rfind(p.substr(0, patlen)); /* s.len-patlen can be -1 == npos */
if (pos != string::npos && pos == (s.length() - patlen))
res = true;
} else if (p.substr(0, 1) == "^") { /* match at beginning */
if (s.find(p.substr(1)) == 0)
res = true;
} else { /* match everywhere */
if (s.find(p) != std::string::npos)
if (s.find(p) != string::npos)
res = true;
}
if (res)