summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/io/qipaddress.cpp3
-rw-r--r--tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp8
2 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp
index ef0ca0269e..47cbbe066a 100644
--- a/src/corelib/io/qipaddress.cpp
+++ b/src/corelib/io/qipaddress.cpp
@@ -111,6 +111,9 @@ static bool parseIp4Internal(IPv4Address &address, const char *ptr, bool acceptL
return false;
else if (dotCount == 3 || *endptr == '\0')
return true;
+ if (*endptr != '.')
+ return false;
+
++dotCount;
ptr = endptr + 1;
}
diff --git a/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp b/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp
index 3e16d3b871..0addd89ebf 100644
--- a/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp
+++ b/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp
@@ -186,6 +186,7 @@ void tst_QIpAddress::invalidParseIp4_data()
QTest::newRow("..") << "..";
QTest::newRow("...") << "...";
QTest::newRow("....") << "....";
+ QTest::newRow(".1.2.3") << ".1.2.3";
QTest::newRow("1.") << "1.";
QTest::newRow("1.2.") << "1.2.";
QTest::newRow("1.2.3.") << "1.2.3.";
@@ -214,9 +215,15 @@ void tst_QIpAddress::invalidParseIp4_data()
QTest::newRow("-1.1") << "-1.1";
QTest::newRow("1.-1") << "1.-1";
QTest::newRow("1.1.1.-1") << "1.1.1.-1";
+ QTest::newRow("300-05") << "300-05";
+ QTest::newRow("127.-1") << "127.-1";
+ QTest::newRow("-127-10") << "-127-10";
+ QTest::newRow("198.-16") << "198-16";
+ QTest::newRow("-127.-0.") << "-127.-0.";
// letters
QTest::newRow("abc") << "abc";
+ QTest::newRow("localhost") << "localhost";
QTest::newRow("1.2.3a.4") << "1.2.3a.4";
QTest::newRow("a.2.3.4") << "a.2.3.4";
QTest::newRow("1.2.3.4a") << "1.2.3.4a";
@@ -249,6 +256,7 @@ void tst_QIpAddress::ip4ToString_data()
QTest::newRow("0.0.0.0") << 0u << "0.0.0.0";
QTest::newRow("1.2.3.4") << 0x01020304u << "1.2.3.4";
+ QTest::newRow("127.0.0.1") << 0x7f000001u << "127.0.0.1";
QTest::newRow("111.222.33.44") << 0x6fde212cu << "111.222.33.44";
QTest::newRow("255.255.255.255") << 0xffffffffu << "255.255.255.255";
}