mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-29 07:25:53 +02:00
fixed GH #1570: IPv6AddressImpl::toString() returns wrong output for IPv6 address "::"
This commit is contained in:
parent
c2aca1d109
commit
a401d22a28
@ -432,13 +432,16 @@ std::string IPv6AddressImpl::toString() const
|
|||||||
else
|
else
|
||||||
result.append("::ffff:");
|
result.append("::ffff:");
|
||||||
const UInt8* bytes = reinterpret_cast<const UInt8*>(&_addr);
|
const UInt8* bytes = reinterpret_cast<const UInt8*>(&_addr);
|
||||||
NumberFormatter::append(result, bytes[12]);
|
if (bytes[12] != 0) // only 0.0.0.0 can start with zero
|
||||||
result.append(".");
|
{
|
||||||
NumberFormatter::append(result, bytes[13]);
|
NumberFormatter::append(result, bytes[12]);
|
||||||
result.append(".");
|
result.append(".");
|
||||||
NumberFormatter::append(result, bytes[14]);
|
NumberFormatter::append(result, bytes[13]);
|
||||||
result.append(".");
|
result.append(".");
|
||||||
NumberFormatter::append(result, bytes[15]);
|
NumberFormatter::append(result, bytes[14]);
|
||||||
|
result.append(".");
|
||||||
|
NumberFormatter::append(result, bytes[15]);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -85,6 +85,10 @@ void IPAddressTest::testStringConv6()
|
|||||||
IPAddress ia6(32, IPAddress::IPv6);
|
IPAddress ia6(32, IPAddress::IPv6);
|
||||||
assert (ia6.family() == IPAddress::IPv6);
|
assert (ia6.family() == IPAddress::IPv6);
|
||||||
assert (ia6.toString() == "ffff:ffff::");
|
assert (ia6.toString() == "ffff:ffff::");
|
||||||
|
|
||||||
|
IPAddress ia7("::");
|
||||||
|
assert (ia7.family() == IPAddress::IPv6);
|
||||||
|
assert (ia7.toString() == "::");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user