mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
fix GH #931: make strToInt() more strict in what it accepts
This commit is contained in:
@@ -74,28 +74,12 @@ private:
|
||||
assert(Poco::strToInt("0", result, 10)); assert(result == 0);
|
||||
assert(Poco::strToInt("000", result, 10)); assert(result == 0);
|
||||
|
||||
if (123 < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt(" 123 ", result, 10)); assert(result == 123); }
|
||||
if (123 < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt(" 123", result, 10)); assert(result == 123); }
|
||||
if (123 < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("123 ", result, 10)); assert(result == 123); }
|
||||
if (std::numeric_limits<T>::is_signed && (-123 > std::numeric_limits<T>::min()))
|
||||
{ assert(Poco::strToInt("-123", result, 10)); assert(result == -123); }
|
||||
if (0x123 < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("123", result, 0x10)); assert(result == 0x123); }
|
||||
if (0x12ab < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("12AB", result, 0x10)); assert(result == 0x12ab); }
|
||||
if (0x12ab < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("0X12AB", result, 0x10)); assert(result == 0x12ab); }
|
||||
if (0x12ab < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("0x12AB", result, 0x10)); assert(result == 0x12ab); }
|
||||
if (0x12ab < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("0x12aB", result, 0x10)); assert(result == 0x12ab); }
|
||||
if (0x98fe < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("0X98Fe", result, 0x10)); assert(result == 0x98fe); }
|
||||
if (123 < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("0x0", result, 0x10)); assert(result == 0); }
|
||||
if (123 < std::numeric_limits<T>::max())
|
||||
{ assert(Poco::strToInt("00", result, 0x10)); assert(result == 0); }
|
||||
if (0123 < std::numeric_limits<T>::max())
|
||||
|
||||
Reference in New Issue
Block a user