mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Handle whitespace separating an 'ip port' correctly (RIPD-552)
This commit is contained in:
committed by
Vinnie Falco
parent
a3fe089367
commit
624a803955
@@ -42,6 +42,20 @@ bool expect (InputStream& is, char v)
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Require and consume whitespace from the input.
|
||||
@return `true` if the character matched.
|
||||
*/
|
||||
template <typename InputStream>
|
||||
bool expect_whitespace (InputStream& is)
|
||||
{
|
||||
char c;
|
||||
if (is.get(c) && isspace(c))
|
||||
return true;
|
||||
is.unget();
|
||||
is.setstate (std::ios_base::failbit);
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Used to disambiguate 8-bit integers from characters. */
|
||||
template <typename IntType>
|
||||
struct integer_holder
|
||||
|
||||
@@ -79,14 +79,14 @@ Endpoint Endpoint::from_string_altform (std::string const& s)
|
||||
|
||||
if (is.rdbuf()->in_avail()>0)
|
||||
{
|
||||
if (! IP::detail::expect (is, ' '))
|
||||
if (! IP::detail::expect_whitespace (is))
|
||||
return Endpoint();
|
||||
|
||||
while (is.rdbuf()->in_avail()>0)
|
||||
{
|
||||
char c;
|
||||
is.get(c);
|
||||
if (c != ' ')
|
||||
if (!isspace (c))
|
||||
{
|
||||
is.unget();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user