fix parsing of IP literals in URIs, added test for it
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55864 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -442,7 +442,7 @@ const char* wxURI::ParseServer(const char* uri)
|
|||||||
{
|
{
|
||||||
m_hostType = wxURI_IPV6ADDRESS;
|
m_hostType = wxURI_IPV6ADDRESS;
|
||||||
|
|
||||||
m_server.assign(start, uri - start - 1);
|
m_server.assign(start + 1, uri - start - 1);
|
||||||
++uri;
|
++uri;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -453,7 +453,7 @@ const char* wxURI::ParseServer(const char* uri)
|
|||||||
{
|
{
|
||||||
m_hostType = wxURI_IPVFUTURE;
|
m_hostType = wxURI_IPVFUTURE;
|
||||||
|
|
||||||
m_server.assign(start, uri - start - 1);
|
m_server.assign(start + 1, uri - start - 1);
|
||||||
++uri;
|
++uri;
|
||||||
}
|
}
|
||||||
else // unrecognized IP literal
|
else // unrecognized IP literal
|
||||||
@@ -468,7 +468,7 @@ const char* wxURI::ParseServer(const char* uri)
|
|||||||
{
|
{
|
||||||
m_hostType = wxURI_IPV4ADDRESS;
|
m_hostType = wxURI_IPV4ADDRESS;
|
||||||
|
|
||||||
m_server.assign(start, uri - start - 1);
|
m_server.assign(start, uri - start);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -45,6 +45,7 @@ private:
|
|||||||
CPPUNIT_TEST_SUITE( URITestCase );
|
CPPUNIT_TEST_SUITE( URITestCase );
|
||||||
CPPUNIT_TEST( IPv4 );
|
CPPUNIT_TEST( IPv4 );
|
||||||
CPPUNIT_TEST( IPv6 );
|
CPPUNIT_TEST( IPv6 );
|
||||||
|
CPPUNIT_TEST( Server );
|
||||||
CPPUNIT_TEST( Paths );
|
CPPUNIT_TEST( Paths );
|
||||||
CPPUNIT_TEST( NormalResolving );
|
CPPUNIT_TEST( NormalResolving );
|
||||||
CPPUNIT_TEST( ComplexResolving );
|
CPPUNIT_TEST( ComplexResolving );
|
||||||
@@ -65,6 +66,7 @@ private:
|
|||||||
|
|
||||||
void IPv4();
|
void IPv4();
|
||||||
void IPv6();
|
void IPv6();
|
||||||
|
void Server();
|
||||||
void Paths();
|
void Paths();
|
||||||
void NormalResolving();
|
void NormalResolving();
|
||||||
void ComplexResolving();
|
void ComplexResolving();
|
||||||
@@ -103,6 +105,9 @@ URITestCase::URITestCase()
|
|||||||
#define URI_ASSERT_HOSTTYPE_EQUAL(uri, expected) \
|
#define URI_ASSERT_HOSTTYPE_EQUAL(uri, expected) \
|
||||||
URI_ASSERT_PART_EQUAL((uri), (expected), GetHostType())
|
URI_ASSERT_PART_EQUAL((uri), (expected), GetHostType())
|
||||||
|
|
||||||
|
#define URI_ASSERT_SERVER_EQUAL(uri, expected) \
|
||||||
|
URI_ASSERT_PART_EQUAL((uri), (expected), GetServer())
|
||||||
|
|
||||||
#define URI_ASSERT_PATH_EQUAL(uri, expected) \
|
#define URI_ASSERT_PATH_EQUAL(uri, expected) \
|
||||||
URI_ASSERT_PART_EQUAL((uri), (expected), GetPath())
|
URI_ASSERT_PART_EQUAL((uri), (expected), GetPath())
|
||||||
|
|
||||||
@@ -157,6 +162,18 @@ void URITestCase::IPv6()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void URITestCase::Server()
|
||||||
|
{
|
||||||
|
URI_ASSERT_SERVER_EQUAL("http://foo/", "foo");
|
||||||
|
URI_ASSERT_SERVER_EQUAL("http://foo-bar/", "foo-bar");
|
||||||
|
URI_ASSERT_SERVER_EQUAL("http://foo/bar/", "foo");
|
||||||
|
URI_ASSERT_SERVER_EQUAL("http://192.168.1.0/", "192.168.1.0");
|
||||||
|
URI_ASSERT_SERVER_EQUAL("http://192.168.1.17/", "192.168.1.17");
|
||||||
|
URI_ASSERT_SERVER_EQUAL("http://192.168.1.255/", "192.168.1.255");
|
||||||
|
URI_ASSERT_SERVER_EQUAL("http://192.168.1.1/index.html", "192.168.1.1");
|
||||||
|
URI_ASSERT_SERVER_EQUAL("http://[aa:aa:aa:aa::aa:aa]/foo", "aa:aa:aa:aa::aa:aa");
|
||||||
|
}
|
||||||
|
|
||||||
void URITestCase::Paths()
|
void URITestCase::Paths()
|
||||||
{
|
{
|
||||||
URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/../path",
|
URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/../path",
|
||||||
|
Reference in New Issue
Block a user