mirror of
https://github.com/wownero/wownero.git
synced 2026-10-17 15:41:44 +02:00
Merge pull request #11104
aa94914 epee: fix hex separator handling (questfever)
ACKs: selsta, jpk68
This commit is contained in:
@@ -134,7 +134,7 @@ namespace epee
|
||||
// should we include a specific character
|
||||
auto include = [](char input) {
|
||||
// we ignore spaces and colons
|
||||
return !std::isspace(input) && input != ':';
|
||||
return !std::isspace(static_cast<unsigned char>(input)) && input != ':';
|
||||
};
|
||||
|
||||
// the number of relevant characters to decode
|
||||
@@ -153,7 +153,7 @@ namespace epee
|
||||
|
||||
// convert a single hex character to an unsigned integer
|
||||
auto char_to_int = [](const char *input) {
|
||||
switch (std::tolower(*input)) {
|
||||
switch (std::tolower(static_cast<unsigned char>(*input))) {
|
||||
case '0': return 0;
|
||||
case '1': return 1;
|
||||
case '2': return 2;
|
||||
@@ -184,6 +184,9 @@ namespace epee
|
||||
|
||||
// convert two matching characters to int
|
||||
auto high = char_to_int(data++);
|
||||
while (data != src.end() && !include(*data)) {
|
||||
++data;
|
||||
}
|
||||
auto low = char_to_int(data++);
|
||||
|
||||
result.push_back(high << 4 | low);
|
||||
|
||||
@@ -1221,6 +1221,9 @@ TEST(HexLocale, String)
|
||||
hex.assign("00:ff 0f:f0");
|
||||
EXPECT_EQ(source, epee::from_hex_locale::to_vector(hex));
|
||||
|
||||
hex.assign("0:0 f f 0:f f:0");
|
||||
EXPECT_EQ(source, epee::from_hex_locale::to_vector(hex));
|
||||
|
||||
hex.append("f0");
|
||||
EXPECT_EQ(source, epee::from_hex_locale::to_vector(boost::string_ref{hex.data(), hex.size() - 2}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user