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