mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 03:34:29 +03:00
Fix utils::string::ssplit() to handle delimiter in the end of string
This closes #1743.
This commit is contained in:
committed by
Felipe Zimmerle
parent
5018358371
commit
5e65d560f8
@@ -178,9 +178,14 @@ std::vector<std::string> ssplit(std::string str, char delimiter) {
|
||||
std::vector<std::string> internal;
|
||||
std::stringstream ss(str); // Turn the string into a stream.
|
||||
std::string tok;
|
||||
ssize_t n = str.length();
|
||||
int i = 0;
|
||||
|
||||
while (getline(ss, tok, delimiter)) {
|
||||
internal.push_back(tok);
|
||||
n -= tok.length();
|
||||
if (i > 0) n--;
|
||||
internal.push_back(n == 1 ? tok + delimiter : tok);
|
||||
i++;
|
||||
}
|
||||
|
||||
return internal;
|
||||
|
Reference in New Issue
Block a user