Merge branch 'uri-path-fixes'
Minor fixes for parsing URLs in wxURI. See https://github.com/wxWidgets/wxWidgets/pull/1239
This commit is contained in:
@@ -532,6 +532,21 @@ const char* wxURI::ParsePath(const char* uri)
|
|||||||
return uri;
|
return uri;
|
||||||
|
|
||||||
const bool isAbs = *uri == '/';
|
const bool isAbs = *uri == '/';
|
||||||
|
|
||||||
|
// From RFC 3986: when authority is present, the path must either be empty
|
||||||
|
// or begin with a slash ("/") character. When authority is not present,
|
||||||
|
// the path cannot begin with two slashes.
|
||||||
|
if ( m_userinfo.empty() && m_server.empty() && m_port.empty() )
|
||||||
|
{
|
||||||
|
if ( isAbs && uri[1] == '/' )
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( !isAbs )
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isAbs )
|
if ( isAbs )
|
||||||
m_path += *uri++;
|
m_path += *uri++;
|
||||||
|
|
||||||
|
@@ -96,7 +96,7 @@ URITestCase::URITestCase()
|
|||||||
|
|
||||||
// apply the given accessor to the URI, check that the result is as expected
|
// apply the given accessor to the URI, check that the result is as expected
|
||||||
#define URI_ASSERT_PART_EQUAL(uri, expected, accessor) \
|
#define URI_ASSERT_PART_EQUAL(uri, expected, accessor) \
|
||||||
CPPUNIT_ASSERT_EQUAL(expected, wxURI(uri).accessor)
|
CHECK(wxURI(uri).accessor == expected)
|
||||||
|
|
||||||
#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())
|
||||||
@@ -189,6 +189,13 @@ void URITestCase::Paths()
|
|||||||
|
|
||||||
URI_ASSERT_PART_EQUAL("path/john/../../../joe",
|
URI_ASSERT_PART_EQUAL("path/john/../../../joe",
|
||||||
"../joe", BuildURI());
|
"../joe", BuildURI());
|
||||||
|
|
||||||
|
// According to RFC 3986, when the authority is present, the path must
|
||||||
|
// begin with a slash (or be empty) and when there is no authority, the
|
||||||
|
// path cannot begin with two slashes, so check for this.
|
||||||
|
URI_ASSERT_PATH_EQUAL("http://good.com:8042BADPATH", "");
|
||||||
|
URI_ASSERT_PATH_EQUAL("http://good.com:8042/GOODPATH", "/GOODPATH");
|
||||||
|
URI_ASSERT_PATH_EQUAL("//BADPATH", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void URITestCase::UserAndPass()
|
void URITestCase::UserAndPass()
|
||||||
|
Reference in New Issue
Block a user