diff options
-rw-r--r-- | contrib/epee/src/wipeable_string.cpp | 7 | ||||
-rw-r--r-- | tests/unit_tests/wipeable_string.cpp | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/contrib/epee/src/wipeable_string.cpp b/contrib/epee/src/wipeable_string.cpp index 4209b71bf..4928db172 100644 --- a/contrib/epee/src/wipeable_string.cpp +++ b/contrib/epee/src/wipeable_string.cpp @@ -188,13 +188,14 @@ void wipeable_string::split(std::vector<wipeable_string> &fields) const while (len--) { const char c = *ptr++; - if (c != ' ') + const bool space_prev = space; + space = std::isspace(c); + if (!space) { - if (space) + if (space_prev) fields.push_back({}); fields.back().push_back(c); } - space = c == ' '; } } diff --git a/tests/unit_tests/wipeable_string.cpp b/tests/unit_tests/wipeable_string.cpp index 44e050c5c..9911bd6f4 100644 --- a/tests/unit_tests/wipeable_string.cpp +++ b/tests/unit_tests/wipeable_string.cpp @@ -182,6 +182,7 @@ TEST(wipeable_string, split) ASSERT_TRUE(check_split(" foo bar baz ", {"foo", "bar", "baz"})); ASSERT_TRUE(check_split(" foo bar baz", {"foo", "bar", "baz"})); ASSERT_TRUE(check_split("foo bar baz ", {"foo", "bar", "baz"})); + ASSERT_TRUE(check_split("\tfoo\n bar\r\nbaz", {"foo", "bar", "baz"})); } TEST(wipeable_string, parse_hexstr) |