Browse Source

Fixed a bug when parsing IP address strings

tags/2021-05-28
ed 7 years ago
parent
commit
6f65cf0f7b
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      modules/juce_core/network/juce_IPAddress.cpp

+ 6
- 3
modules/juce_core/network/juce_IPAddress.cpp View File

@@ -116,15 +116,18 @@ IPAddress::IPAddress (const String& adr)
if (tokens.contains ({})) // if :: shorthand has been used if (tokens.contains ({})) // if :: shorthand has been used
{ {
int idx = tokens.indexOf (StringRef());
auto idx = tokens.indexOf ({});
tokens.set (idx, "0"); 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) while (tokens.size() < 8)
tokens.insert (idx, "0"); tokens.insert (idx, "0");
} }
tokens.removeEmptyStrings();
for (int i = 0; i < 8; ++i) for (int i = 0; i < 8; ++i)
{ {
if (i == 6 && isIPv4MappedAddress (IPAddress (address, true))) if (i == 6 && isIPv4MappedAddress (IPAddress (address, true)))


Loading…
Cancel
Save