From 6f65cf0f7b9f20b452f906e62a982e6871ddd3bd Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 17 May 2018 14:36:28 +0100 Subject: [PATCH] Fixed a bug when parsing IP address strings --- modules/juce_core/network/juce_IPAddress.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/juce_core/network/juce_IPAddress.cpp b/modules/juce_core/network/juce_IPAddress.cpp index 7607f071f0..bb26b4b57c 100644 --- a/modules/juce_core/network/juce_IPAddress.cpp +++ b/modules/juce_core/network/juce_IPAddress.cpp @@ -116,15 +116,18 @@ IPAddress::IPAddress (const String& adr) if (tokens.contains ({})) // if :: shorthand has been used { - int idx = tokens.indexOf (StringRef()); + auto idx = tokens.indexOf ({}); tokens.set (idx, "0"); + tokens.removeEmptyStrings(); + + // mapped IPv4 address will be treated as a single token, so pad the end of the StringArray + if (tokens[tokens.size() - 1].containsChar ('.')) + tokens.add ({}); while (tokens.size() < 8) tokens.insert (idx, "0"); } - tokens.removeEmptyStrings(); - for (int i = 0; i < 8; ++i) { if (i == 6 && isIPv4MappedAddress (IPAddress (address, true)))