Skip to content
Permalink
Browse files

wipeable_string: split - treat CR, LF and Tabs as separators

  • Loading branch information
xiphon committed Feb 12, 2020
1 parent 51873fe commit 0078ce7fac6a205341fee659b7f5adefa7f0b7aa
Showing with 5 additions and 3 deletions.
  1. +4 −3 contrib/epee/src/wipeable_string.cpp
  2. +1 −0 tests/unit_tests/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 == ' ';
}
}

@@ -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)

0 comments on commit 0078ce7

Please sign in to comment.
You can’t perform that action at this time.