Make parsing wxURI paths more conforming to RFC 3986
Don't recognize the "path" following the port number without a slash as a path, this is invalid according to the RFC. Also require two leading slashes for URIs without the authority part.
This commit is contained in:
committed by
Vadim Zeitlin
parent
466a2d000f
commit
b7f3a2b30f
@@ -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++;
|
||||||
|
|
||||||
|
@@ -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