mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
opkg_manager: fix invalid match with -foo$ "regex"
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
committed by
svenhoefer
parent
70e1891b36
commit
8f0e74a3bf
@@ -365,13 +365,14 @@ bool COPKGManager::badpackage(std::string &s)
|
|||||||
bool res = false;
|
bool res = false;
|
||||||
/* poor man's regex :-) only supported are "^" and "$" */
|
/* poor man's regex :-) only supported are "^" and "$" */
|
||||||
if (p.substr(patlen, 1) == "$") { /* match at end */
|
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;
|
res = true;
|
||||||
} else if (p.substr(0, 1) == "^") { /* match at beginning */
|
} else if (p.substr(0, 1) == "^") { /* match at beginning */
|
||||||
if (s.find(p.substr(1)) == 0)
|
if (s.find(p.substr(1)) == 0)
|
||||||
res = true;
|
res = true;
|
||||||
} else { /* match everywhere */
|
} else { /* match everywhere */
|
||||||
if (s.find(p) != std::string::npos)
|
if (s.find(p) != string::npos)
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
if (res)
|
if (res)
|
||||||
|
Reference in New Issue
Block a user