Improve wxURI parsing
- Update parsing IPvX addresses to follow RFC and add many more tests. - Rework authority parsing for RFC edge cases. - Fix a couple of other extreme edge cases. Closes #23360.
This commit is contained in:
parent
11358d7dcc
commit
e1c3962aa9
3 changed files with 498 additions and 336 deletions
|
|
@ -162,6 +162,8 @@ protected:
|
||||||
static bool IsAlpha(char c);
|
static bool IsAlpha(char c);
|
||||||
static bool IsDigit(char c);
|
static bool IsDigit(char c);
|
||||||
static bool IsEndPath(char c);
|
static bool IsEndPath(char c);
|
||||||
|
static bool IsPCharNCNE(char c);
|
||||||
|
static bool IsPCharNE(char c);
|
||||||
|
|
||||||
wxString m_scheme;
|
wxString m_scheme;
|
||||||
wxString m_path;
|
wxString m_path;
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,10 @@ bool wxURI::operator==(const wxURI& uri) const
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// IsReference
|
// IsReference
|
||||||
//
|
//
|
||||||
// if there is no authority or scheme, it is a reference
|
// if there is no authority or scheme, it is a reference.
|
||||||
|
// May be needed to have an RFC Deviation here where file doesn't need to
|
||||||
|
// have a server so that raw file paths work as users expect. I.E.:
|
||||||
|
// return !HasScheme() || (!HasServer() && m_scheme != wxT("file"));
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxURI::IsReference() const
|
bool wxURI::IsReference() const
|
||||||
|
|
@ -296,8 +299,6 @@ bool wxURI::IsReference() const
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// IsRelative
|
// IsRelative
|
||||||
//
|
|
||||||
// FIXME: may need refinement
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxURI::IsRelative() const
|
bool wxURI::IsRelative() const
|
||||||
|
|
@ -370,20 +371,57 @@ const char* wxURI::ParseScheme(const char *uri)
|
||||||
|
|
||||||
const char* wxURI::ParseAuthority(const char* uri)
|
const char* wxURI::ParseAuthority(const char* uri)
|
||||||
{
|
{
|
||||||
// authority = [ userinfo "@" ] host [ ":" port ]
|
// URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
|
||||||
if ( uri[0] == '/' && uri[1] == '/' )
|
// hier-part = "//" authority path-abempty
|
||||||
|
bool leadswithdoubleslash = uri[0] == '/' && uri[1] == '/';
|
||||||
|
if(leadswithdoubleslash)
|
||||||
{
|
{
|
||||||
//skip past the two slashes
|
//skip past the two slashes
|
||||||
uri += 2;
|
uri += 2;
|
||||||
|
}
|
||||||
|
|
||||||
// ############# DEVIATION FROM RFC #########################
|
// ############# DEVIATION FROM RFC #########################
|
||||||
// Don't parse the server component for file URIs
|
// Evidence shows us that users expect us to parse the
|
||||||
if(m_scheme != "file")
|
// server component in the case of [server][#fragment].
|
||||||
|
// Otherwise they don't want us to parse the server at all
|
||||||
|
// for file uris.
|
||||||
|
if (m_scheme == "file") // RFC 8089 allows for leading "//" with file
|
||||||
|
{ // look for [server][#fragment] case
|
||||||
|
bool serverfragmentfound = false;
|
||||||
|
const char* uristart = uri;
|
||||||
|
uri = ParseServer(uri);
|
||||||
|
if(HasServer())
|
||||||
{
|
{
|
||||||
//normal way
|
uri = ParseFragment(uri);
|
||||||
uri = ParseUserInfo(uri);
|
serverfragmentfound = HasFragment();
|
||||||
|
}
|
||||||
|
if(!serverfragmentfound)
|
||||||
|
{ // nope... clear fields, return to point after opening slashes
|
||||||
|
uri = uristart;
|
||||||
|
m_server.erase();
|
||||||
|
m_fields &= ~wxURI_SERVER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(leadswithdoubleslash)
|
||||||
|
{ // normal RFC-based authority parsing
|
||||||
|
// authority = [ userinfo "@" ] host [ ":" port ]
|
||||||
|
// file-hier-part = ( "//" auth-path ) / local-path
|
||||||
|
const char* uristart = uri;
|
||||||
|
uri = ParseUserInfo(uri);
|
||||||
|
uri = ParseServer(uri);
|
||||||
|
if (!HasServer() && HasUserInfo()) // in practice this case doesn't happen without scheme-based parsing
|
||||||
|
{ // userinfo can't exist without host, backtrack and reparse
|
||||||
|
m_userinfo.erase();
|
||||||
|
m_fields &= ~wxURI_USERINFO;
|
||||||
|
uri = uristart;
|
||||||
uri = ParseServer(uri);
|
uri = ParseServer(uri);
|
||||||
return ParsePort(uri);
|
}
|
||||||
|
uri = ParsePort(uri);
|
||||||
|
if (!HasServer()) // in practice this case doesn't happen without scheme-based parsing
|
||||||
|
{
|
||||||
|
m_port.erase(); // port can't exist without host
|
||||||
|
m_fields &= ~wxURI_PORT;
|
||||||
|
uri = uristart - 2; // nothing found, skip to before the leading "//"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -452,7 +490,7 @@ const char* wxURI::ParseServer(const char* uri)
|
||||||
}
|
}
|
||||||
else // IPv4 or a reg-name
|
else // IPv4 or a reg-name
|
||||||
{
|
{
|
||||||
if (ParseIPv4address(uri))
|
if (ParseIPv4address(uri) && (!*uri || *uri == '/' || *uri == ':'))
|
||||||
{
|
{
|
||||||
m_hostType = wxURI_IPV4ADDRESS;
|
m_hostType = wxURI_IPV4ADDRESS;
|
||||||
|
|
||||||
|
|
@ -502,95 +540,79 @@ const char* wxURI::ParsePort(const char* uri)
|
||||||
|
|
||||||
const char* wxURI::ParsePath(const char* uri)
|
const char* wxURI::ParsePath(const char* uri)
|
||||||
{
|
{
|
||||||
/// hier-part = "//" authority path-abempty
|
// hier-part = "//" authority path-abempty
|
||||||
/// / path-absolute
|
// / path-absolute
|
||||||
/// / path-rootless
|
// / path-rootless
|
||||||
/// / path-empty
|
// / path-empty
|
||||||
///
|
//
|
||||||
/// relative-part = "//" authority path-abempty
|
// relative-part = "//" authority path-abempty
|
||||||
/// / path-absolute
|
// / path-absolute
|
||||||
/// / path-noscheme
|
// / path-noscheme
|
||||||
/// / path-empty
|
// / path-empty
|
||||||
///
|
//
|
||||||
/// path-abempty = *( "/" segment )
|
// path-abempty = *( "/" segment )
|
||||||
/// path-absolute = "/" [ segment-nz *( "/" segment ) ]
|
// path-absolute = "/" [ segment-nz *( "/" segment ) ]
|
||||||
/// path-noscheme = segment-nz-nc *( "/" segment )
|
// path-noscheme = segment-nz-nc *( "/" segment )
|
||||||
/// path-rootless = segment-nz *( "/" segment )
|
// path-rootless = segment-nz *( "/" segment )
|
||||||
/// path-empty = 0<pchar>
|
// path-empty = 0<pchar>
|
||||||
///
|
//
|
||||||
/// segment = *pchar
|
// segment = *pchar
|
||||||
/// segment-nz = 1*pchar
|
// segment-nz = 1*pchar
|
||||||
/// segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
|
// segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
|
||||||
/// ; non-zero-length segment without any colon ":"
|
// ; non-zero-length segment without any colon ":"
|
||||||
///
|
//
|
||||||
/// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
||||||
|
|
||||||
if ( IsEndPath(*uri) )
|
if (IsEndPath(*uri)
|
||||||
|
// 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 slash characters ("//").
|
||||||
|
|| (m_server.length() ? (!(!*uri || *uri == '/')) : (*uri == '/' && *(uri+1) == '/')))
|
||||||
return uri;
|
return uri;
|
||||||
|
const char* uristart = uri;
|
||||||
const bool isAbs = *uri == '/';
|
const bool isAbsolute = *uri == '/';
|
||||||
|
if (isAbsolute)
|
||||||
// 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 )
|
|
||||||
m_path += *uri++;
|
m_path += *uri++;
|
||||||
|
// segment-nz = 1*pchar
|
||||||
wxArrayString segments;
|
while (!IsEndPath(*uri))
|
||||||
wxString segment;
|
|
||||||
for ( ;; )
|
|
||||||
{
|
|
||||||
const bool endPath = IsEndPath(*uri);
|
|
||||||
if ( endPath || *uri == '/' )
|
|
||||||
{
|
{
|
||||||
// end of a segment, look at what we got
|
if (IsPCharNE(*uri) || *uri == '/')
|
||||||
if ( segment == ".." )
|
m_path += *uri++;
|
||||||
{
|
else
|
||||||
if ( !segments.empty() && *segments.rbegin() != ".." )
|
AppendNextEscaped(m_path, uri);
|
||||||
segments.pop_back();
|
|
||||||
else if ( !isAbs )
|
|
||||||
segments.push_back("..");
|
|
||||||
}
|
|
||||||
else if ( segment == "." )
|
|
||||||
{
|
|
||||||
// normally we ignore "." but the last one should be taken into
|
|
||||||
// account as "path/." is the same as "path/" and not just "path"
|
|
||||||
if ( endPath )
|
|
||||||
segments.push_back("");
|
|
||||||
}
|
|
||||||
else // normal segment
|
|
||||||
{
|
|
||||||
segments.push_back(segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( endPath )
|
|
||||||
break;
|
|
||||||
|
|
||||||
segment.clear();
|
|
||||||
++uri;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
m_fields |= wxURI_PATH; //mark the path as valid
|
||||||
if ( IsUnreserved(*uri) || IsSubDelim(*uri) || *uri == ':' || *uri == '@' )
|
}
|
||||||
segment += *uri++;
|
else if (*uri) //Relative path
|
||||||
else
|
{
|
||||||
AppendNextEscaped(segment, uri);
|
if (!HasScheme())
|
||||||
|
{
|
||||||
|
// segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
|
||||||
|
// ; non-zero-length segment without any colon ":"
|
||||||
|
while (!IsEndPath(*uri))
|
||||||
|
{
|
||||||
|
if (IsPCharNCNE(*uri) || *uri == '/')
|
||||||
|
m_path += *uri++;
|
||||||
|
else
|
||||||
|
AppendNextEscaped(m_path, uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// segment-nz = 1*pchar
|
||||||
|
while (!IsEndPath(*uri))
|
||||||
|
{
|
||||||
|
if (IsPCharNE(*uri) || *uri == '/')
|
||||||
|
m_path += *uri++;
|
||||||
|
else
|
||||||
|
AppendNextEscaped(m_path, uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uri != uristart)
|
||||||
|
m_fields |= wxURI_PATH; // mark the path as valid
|
||||||
}
|
}
|
||||||
|
|
||||||
m_path += wxJoin(segments, '/', '\0');
|
|
||||||
m_fields |= wxURI_PATH;
|
|
||||||
|
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -603,8 +625,7 @@ const char* wxURI::ParseQuery(const char* uri)
|
||||||
++uri;
|
++uri;
|
||||||
while ( *uri && *uri != '#' )
|
while ( *uri && *uri != '#' )
|
||||||
{
|
{
|
||||||
if ( IsUnreserved(*uri) || IsSubDelim(*uri) ||
|
if ( IsPCharNE(*uri) || *uri == '/' || *uri == '?' )
|
||||||
*uri == ':' || *uri == '@' || *uri == '/' || *uri == '?' )
|
|
||||||
m_query += *uri++;
|
m_query += *uri++;
|
||||||
else
|
else
|
||||||
AppendNextEscaped(m_query, uri);
|
AppendNextEscaped(m_query, uri);
|
||||||
|
|
@ -625,8 +646,7 @@ const char* wxURI::ParseFragment(const char* uri)
|
||||||
++uri;
|
++uri;
|
||||||
while ( *uri )
|
while ( *uri )
|
||||||
{
|
{
|
||||||
if ( IsUnreserved(*uri) || IsSubDelim(*uri) ||
|
if ( IsPCharNE(*uri) || *uri == '/' || *uri == '?' )
|
||||||
*uri == ':' || *uri == '@' || *uri == '/' || *uri == '?')
|
|
||||||
m_fragment += *uri++;
|
m_fragment += *uri++;
|
||||||
else
|
else
|
||||||
AppendNextEscaped(m_fragment, uri);
|
AppendNextEscaped(m_fragment, uri);
|
||||||
|
|
@ -657,8 +677,8 @@ wxArrayString wxURI::SplitInSegments(const wxString& path)
|
||||||
|
|
||||||
void wxURI::Resolve(const wxURI& base, int flags)
|
void wxURI::Resolve(const wxURI& base, int flags)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(!base.IsReference(),
|
wxASSERT_MSG((!base.IsReference()),
|
||||||
"wxURI to inherit from must not be a reference!");
|
"wxURI to inherit from must not be a reference!");
|
||||||
|
|
||||||
// If we aren't being strict, enable the older (pre-RFC2396) loophole that
|
// If we aren't being strict, enable the older (pre-RFC2396) loophole that
|
||||||
// allows this uri to inherit other properties from the base uri - even if
|
// allows this uri to inherit other properties from the base uri - even if
|
||||||
|
|
@ -714,40 +734,47 @@ void wxURI::Resolve(const wxURI& base, int flags)
|
||||||
// Simple path inheritance from base
|
// Simple path inheritance from base
|
||||||
if (!HasPath())
|
if (!HasPath())
|
||||||
{
|
{
|
||||||
// T.path = Base.path;
|
// T.path = Base.path;
|
||||||
m_path = base.m_path;
|
m_path = base.m_path;
|
||||||
m_fields |= wxURI_PATH;
|
m_fields |= wxURI_PATH;
|
||||||
|
|
||||||
|
|
||||||
// if defined(R.query) then
|
// if defined(R.query) then
|
||||||
// T.query = R.query;
|
// T.query = R.query;
|
||||||
// else
|
// else
|
||||||
// T.query = Base.query;
|
// T.query = Base.query;
|
||||||
// endif;
|
// endif;
|
||||||
if (!HasQuery())
|
if (!HasQuery())
|
||||||
{
|
{
|
||||||
m_query = base.m_query;
|
m_query = base.m_query;
|
||||||
m_fields |= wxURI_QUERY;
|
m_fields |= wxURI_QUERY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( m_path.empty() || m_path[0u] != '/' )
|
else
|
||||||
{
|
{
|
||||||
// if (R.path starts-with "/") then
|
// if (R.path starts-with "/") then
|
||||||
// T.path = remove_dot_segments(R.path);
|
// T.path = remove_dot_segments(R.path);
|
||||||
// else
|
// else
|
||||||
// T.path = merge(Base.path, R.path);
|
// T.path = merge(Base.path, R.path);
|
||||||
// T.path = remove_dot_segments(T.path);
|
// T.path = remove_dot_segments(T.path);
|
||||||
// endif;
|
// endif;
|
||||||
// T.query = R.query;
|
// T.query = R.query;
|
||||||
//
|
//
|
||||||
// So we don't do anything for absolute paths and implement merge for
|
// So we just normalize (./.. handling) absolute paths and
|
||||||
// the relative ones
|
// merge the two together if the one we are resolving with
|
||||||
|
// (right side/operand) is relative
|
||||||
|
|
||||||
wxArrayString our(SplitInSegments(m_path)),
|
wxArrayString our(SplitInSegments(m_path)),
|
||||||
result(SplitInSegments(base.m_path));
|
result(SplitInSegments(base.m_path));
|
||||||
|
bool isRightAbsolute = !m_path.empty() && m_path[0u] == '/';
|
||||||
|
|
||||||
if ( !result.empty() )
|
if ( !result.empty() )
|
||||||
result.pop_back();
|
{
|
||||||
|
if ( isRightAbsolute )
|
||||||
|
result.clear(); // just resolve right side
|
||||||
|
else
|
||||||
|
result.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
if ( our.empty() )
|
if ( our.empty() )
|
||||||
{
|
{
|
||||||
|
|
@ -760,7 +787,8 @@ void wxURI::Resolve(const wxURI& base, int flags)
|
||||||
const wxArrayString::const_iterator end = our.end();
|
const wxArrayString::const_iterator end = our.end();
|
||||||
for ( wxArrayString::const_iterator i = our.begin(); i != end; ++i )
|
for ( wxArrayString::const_iterator i = our.begin(); i != end; ++i )
|
||||||
{
|
{
|
||||||
if ( i->empty() || *i == "." )
|
//. _or_ ./ - remove (6.2.2.3. Path Segment Normalization)
|
||||||
|
if ( i->empty() || *i == "." || *i == "/")
|
||||||
{
|
{
|
||||||
// as in ParsePath(), while normally we ignore the empty
|
// as in ParsePath(), while normally we ignore the empty
|
||||||
// segments, we need to take account of them at the end
|
// segments, we need to take account of them at the end
|
||||||
|
|
@ -769,7 +797,8 @@ void wxURI::Resolve(const wxURI& base, int flags)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *i == ".." )
|
//.. _or_ ../ - remove as well as previous path if it exists (6.2.2.3)
|
||||||
|
if ( *i == ".." || *i == "../")
|
||||||
{
|
{
|
||||||
if ( !result.empty() )
|
if ( !result.empty() )
|
||||||
{
|
{
|
||||||
|
|
@ -796,6 +825,7 @@ void wxURI::Resolve(const wxURI& base, int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
//T.fragment = R.fragment;
|
//T.fragment = R.fragment;
|
||||||
|
// (done implicitly)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
@ -809,7 +839,7 @@ void wxURI::Resolve(const wxURI& base, int flags)
|
||||||
bool wxURI::ParseH16(const char*& uri)
|
bool wxURI::ParseH16(const char*& uri)
|
||||||
{
|
{
|
||||||
// h16 = 1*4HEXDIG
|
// h16 = 1*4HEXDIG
|
||||||
if(!IsHex(*++uri))
|
if(!IsHex(*uri))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(IsHex(*++uri) && IsHex(*++uri) && IsHex(*++uri))
|
if(IsHex(*++uri) && IsHex(*++uri) && IsHex(*++uri))
|
||||||
|
|
@ -837,26 +867,29 @@ bool wxURI::ParseIPv4address(const char*& uri)
|
||||||
// / "2" %x30-34 DIGIT ; 200-249
|
// / "2" %x30-34 DIGIT ; 200-249
|
||||||
// / "25" %x30-35 ; 250-255
|
// / "25" %x30-35 ; 250-255
|
||||||
size_t iIPv4 = 0;
|
size_t iIPv4 = 0;
|
||||||
|
const char* uriOrig = uri;
|
||||||
if (IsDigit(*uri))
|
if (IsDigit(*uri))
|
||||||
{
|
{
|
||||||
++iIPv4;
|
++iIPv4;
|
||||||
|
|
||||||
|
|
||||||
//each ip part must be between 0-255 (dupe of version in for loop)
|
//each ip part must be between 0-255 (dupe of version in for loop)
|
||||||
if( IsDigit(*++uri) && IsDigit(*++uri) &&
|
if( (IsDigit(*++uri) && IsDigit(*++uri) &&
|
||||||
//100 or less (note !)
|
//100 or less (note !)
|
||||||
!( (*(uri-2) < '2') ||
|
!( (*(uri-2) == '1') ||
|
||||||
//240 or less
|
//240 or less
|
||||||
(*(uri-2) == '2' &&
|
(*(uri-2) == '2' &&
|
||||||
(*(uri-1) < '5' || (*(uri-1) == '5' && *uri <= '5'))
|
(*(uri-1) < '5' || (*(uri-1) == '5' && *uri <= '5'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
) || ((uri - uriOrig >= 2) && (*uriOrig == '0')) // leading 0
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IsDigit(*uri))++uri;
|
if(IsDigit(*uri))
|
||||||
|
++uri;
|
||||||
|
|
||||||
//compilers should unroll this loop
|
//compilers should unroll this loop
|
||||||
for(; iIPv4 < 4; ++iIPv4)
|
for(; iIPv4 < 4; ++iIPv4)
|
||||||
|
|
@ -865,19 +898,22 @@ bool wxURI::ParseIPv4address(const char*& uri)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//each ip part must be between 0-255
|
//each ip part must be between 0-255
|
||||||
if( IsDigit(*++uri) && IsDigit(*++uri) &&
|
uriOrig = uri;
|
||||||
|
if( (IsDigit(*++uri) && IsDigit(*++uri) &&
|
||||||
//100 or less (note !)
|
//100 or less (note !)
|
||||||
!( (*(uri-2) < '2') ||
|
!( (*(uri-2) == '1') ||
|
||||||
//240 or less
|
//240 or less
|
||||||
(*(uri-2) == '2' &&
|
(*(uri-2) == '2' &&
|
||||||
(*(uri-1) < '5' || (*(uri-1) == '5' && *uri <= '5'))
|
(*(uri-1) < '5' || (*(uri-1) == '5' && *uri <= '5'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
) || ((uri - uriOrig >= 2) && (*uriOrig == '0')) // leading 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(IsDigit(*uri))++uri;
|
if(IsDigit(*uri))
|
||||||
|
++uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return iIPv4 == 4;
|
return iIPv4 == 4;
|
||||||
|
|
@ -895,108 +931,95 @@ bool wxURI::ParseIPv6address(const char*& uri)
|
||||||
// / [ *5( h16 ":" ) h16 ] "::" h16
|
// / [ *5( h16 ":" ) h16 ] "::" h16
|
||||||
// / [ *6( h16 ":" ) h16 ] "::"
|
// / [ *6( h16 ":" ) h16 ] "::"
|
||||||
|
|
||||||
size_t numPrefix = 0,
|
size_t leftHexpairs = 0, rightHexpairs, maxRightHexpairs;
|
||||||
maxPostfix;
|
const char* uristart;
|
||||||
|
bool doublecolon = false;
|
||||||
bool bEndHex = false;
|
if (*uri == ':' && *(uri+1) == ':')
|
||||||
|
doublecolon = true;
|
||||||
for( ; numPrefix < 6; ++numPrefix)
|
else
|
||||||
{
|
{
|
||||||
if(!ParseH16(uri))
|
uristart = uri;
|
||||||
|
if (ParseH16(uri))
|
||||||
{
|
{
|
||||||
--uri;
|
++leftHexpairs;
|
||||||
bEndHex = true;
|
if (*uri == ':' && *(uri+1) == ':')
|
||||||
break;
|
doublecolon = true;
|
||||||
}
|
else
|
||||||
|
{
|
||||||
if(*uri != ':')
|
for (;leftHexpairs < 7;)
|
||||||
{
|
{ // skip up to 6 leading [":" h16] pairs
|
||||||
break;
|
if (*uri == ':')
|
||||||
}
|
{
|
||||||
}
|
++uri; // skip over single colon
|
||||||
|
uristart = uri;
|
||||||
if(!bEndHex && !ParseH16(uri))
|
if (!ParseH16(uri) || (*uri != ':' && *uri))
|
||||||
{
|
{
|
||||||
--uri;
|
uri = uristart;
|
||||||
|
break;
|
||||||
if (numPrefix)
|
}
|
||||||
return false;
|
++leftHexpairs;
|
||||||
|
}
|
||||||
if (*uri == ':')
|
else
|
||||||
{
|
break;
|
||||||
if (*++uri != ':')
|
if (*uri == ':' && *(uri+1) == ':')
|
||||||
return false;
|
{
|
||||||
|
doublecolon = true;
|
||||||
maxPostfix = 5;
|
break;
|
||||||
}
|
}
|
||||||
|
} // [":" h16] skipping loop
|
||||||
|
if (!doublecolon && leftHexpairs == 7 && *uri == ':')
|
||||||
|
++uri; // skip over single colon
|
||||||
|
}//leading h16 :: check
|
||||||
|
}//h16
|
||||||
else
|
else
|
||||||
maxPostfix = 6;
|
uri = uristart;
|
||||||
|
}
|
||||||
|
if (doublecolon)
|
||||||
|
{
|
||||||
|
uri += 2;
|
||||||
|
if (leftHexpairs < 5)
|
||||||
|
maxRightHexpairs = 5 - leftHexpairs;
|
||||||
|
else
|
||||||
|
maxRightHexpairs = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (*uri != ':' || *(uri+1) != ':')
|
if (leftHexpairs < 6)
|
||||||
{
|
maxRightHexpairs = 6 - leftHexpairs;
|
||||||
if (numPrefix != 6)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
while (*--uri != ':') {}
|
|
||||||
++uri;
|
|
||||||
|
|
||||||
const char * const start = uri;
|
|
||||||
//parse ls32
|
|
||||||
// ls32 = ( h16 ":" h16 ) / IPv4address
|
|
||||||
if (ParseH16(uri) && *uri == ':' && ParseH16(uri))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
uri = start;
|
|
||||||
|
|
||||||
if (ParseIPv4address(uri))
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
maxRightHexpairs = 0;
|
||||||
|
}
|
||||||
|
for (rightHexpairs = 0; rightHexpairs < maxRightHexpairs; ++rightHexpairs)
|
||||||
|
{ // skip up to 6 trailing [h16 ":"] pairs
|
||||||
|
uristart = uri;
|
||||||
|
if (!ParseH16(uri) || *uri != ':')
|
||||||
{
|
{
|
||||||
uri += 2;
|
uri = uristart;
|
||||||
|
break;
|
||||||
if (numPrefix > 3)
|
|
||||||
maxPostfix = 0;
|
|
||||||
else
|
|
||||||
maxPostfix = 4 - numPrefix;
|
|
||||||
}
|
}
|
||||||
|
++uri;
|
||||||
}
|
}
|
||||||
|
if (!doublecolon)
|
||||||
bool bAllowAltEnding = maxPostfix == 0;
|
|
||||||
|
|
||||||
for(; maxPostfix != 0; --maxPostfix)
|
|
||||||
{
|
{
|
||||||
if(!ParseH16(uri) || *uri != ':')
|
if (leftHexpairs < 6)
|
||||||
return false;
|
return false;
|
||||||
|
rightHexpairs = leftHexpairs;
|
||||||
|
leftHexpairs = 0;
|
||||||
}
|
}
|
||||||
|
uristart = uri;
|
||||||
if(numPrefix <= 4)
|
if (leftHexpairs < 6 && rightHexpairs < 7) // ls32 = ( h16 ":" h16 ) / IPv4address
|
||||||
{
|
{
|
||||||
const char * const start = uri;
|
if (ParseH16(uri) && *uri++ == ':' && ParseH16(uri) && *uri == ']')
|
||||||
//parse ls32
|
|
||||||
// ls32 = ( h16 ":" h16 ) / IPv4address
|
|
||||||
if (ParseH16(uri) && *uri == ':' && ParseH16(uri))
|
|
||||||
return true;
|
return true;
|
||||||
|
uri = uristart;
|
||||||
uri = start;
|
if (ParseIPv4address(uri) && *uri == ']')
|
||||||
|
|
||||||
if (ParseIPv4address(uri))
|
|
||||||
return true;
|
return true;
|
||||||
|
uri = uristart;
|
||||||
uri = start;
|
|
||||||
|
|
||||||
if (!bAllowAltEnding)
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
if (leftHexpairs < 7 && (doublecolon || rightHexpairs == 7)
|
||||||
if(numPrefix <= 5 && ParseH16(uri))
|
&& ParseH16(uri) && *uri == ']') // final single h16 case or tail end of ending ls32
|
||||||
return true;
|
return true;
|
||||||
|
return doublecolon && *uri == ']'; // can only be empty if a "::" was detecte
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxURI::ParseIPvFuture(const char*& uri)
|
bool wxURI::ParseIPvFuture(const char*& uri)
|
||||||
|
|
@ -1092,3 +1115,14 @@ bool wxURI::IsEndPath(char c)
|
||||||
return c == '\0' || c == '#' || c == '?';
|
return c == '\0' || c == '#' || c == '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
|
||||||
|
// pct-encoded handled outside, NC is for no colon for relative paths
|
||||||
|
bool wxURI::IsPCharNCNE(char c)
|
||||||
|
{
|
||||||
|
return IsUnreserved(c) || IsSubDelim(c) || c == '@' || c == '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxURI::IsPCharNE(char c)
|
||||||
|
{
|
||||||
|
return IsPCharNCNE(c) || c == ':';
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,8 @@ 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( Host );
|
||||||
CPPUNIT_TEST( Paths );
|
CPPUNIT_TEST( Paths );
|
||||||
CPPUNIT_TEST( UserAndPass );
|
|
||||||
CPPUNIT_TEST( NormalResolving );
|
CPPUNIT_TEST( NormalResolving );
|
||||||
CPPUNIT_TEST( ComplexResolving );
|
CPPUNIT_TEST( ComplexResolving );
|
||||||
CPPUNIT_TEST( ReallyComplexResolving );
|
CPPUNIT_TEST( ReallyComplexResolving );
|
||||||
|
|
@ -48,6 +47,7 @@ private:
|
||||||
CPPUNIT_TEST( Comparison );
|
CPPUNIT_TEST( Comparison );
|
||||||
CPPUNIT_TEST( Unescaping );
|
CPPUNIT_TEST( Unescaping );
|
||||||
CPPUNIT_TEST( FileScheme );
|
CPPUNIT_TEST( FileScheme );
|
||||||
|
CPPUNIT_TEST( Normalizing );
|
||||||
#if TEST_URL
|
#if TEST_URL
|
||||||
CPPUNIT_TEST( URLCompat );
|
CPPUNIT_TEST( URLCompat );
|
||||||
#if 0 && wxUSE_PROTOCOL_HTTP
|
#if 0 && wxUSE_PROTOCOL_HTTP
|
||||||
|
|
@ -58,9 +58,8 @@ private:
|
||||||
|
|
||||||
void IPv4();
|
void IPv4();
|
||||||
void IPv6();
|
void IPv6();
|
||||||
void Server();
|
void Host();
|
||||||
void Paths();
|
void Paths();
|
||||||
void UserAndPass();
|
|
||||||
void NormalResolving();
|
void NormalResolving();
|
||||||
void ComplexResolving();
|
void ComplexResolving();
|
||||||
void ReallyComplexResolving();
|
void ReallyComplexResolving();
|
||||||
|
|
@ -70,6 +69,7 @@ private:
|
||||||
void Comparison();
|
void Comparison();
|
||||||
void Unescaping();
|
void Unescaping();
|
||||||
void FileScheme();
|
void FileScheme();
|
||||||
|
void Normalizing();
|
||||||
|
|
||||||
#if TEST_URL
|
#if TEST_URL
|
||||||
void URLCompat();
|
void URLCompat();
|
||||||
|
|
@ -94,27 +94,78 @@ 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) \
|
||||||
CHECK(wxURI(uri).accessor == expected)
|
CHECK(wxURI(uri).accessor == expected)
|
||||||
|
#define URI_ASSERT_HOST_TEST(uri, expectedhost, expectedtype) \
|
||||||
#define URI_ASSERT_HOSTTYPE_EQUAL(uri, expected) \
|
CPPUNIT_ASSERT(wxURI(uri).GetServer() == (expectedhost)); \
|
||||||
URI_ASSERT_PART_EQUAL((uri), (expected), GetHostType())
|
CPPUNIT_ASSERT(wxURI(uri).GetHostType() == (expectedtype))
|
||||||
|
#define URI_ASSERT_HOST_TESTBAD(uri, ne) CPPUNIT_ASSERT(wxURI(uri).GetHostType() != (ne))
|
||||||
#define URI_ASSERT_SERVER_EQUAL(uri, expected) \
|
#define URI_ASSERT_HOST_EQUAL(uri, expected) \
|
||||||
URI_ASSERT_PART_EQUAL((uri), (expected), GetServer())
|
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())
|
||||||
|
#define URI_ASSERT_HOSTTYPE_EQUAL(uri, expected) \
|
||||||
|
URI_ASSERT_PART_EQUAL((uri), (expected), GetHostType())
|
||||||
#define URI_ASSERT_USER_EQUAL(uri, expected) \
|
#define URI_ASSERT_USER_EQUAL(uri, expected) \
|
||||||
URI_ASSERT_PART_EQUAL((uri), (expected), GetUser())
|
URI_ASSERT_PART_EQUAL((uri), (expected), GetUser())
|
||||||
|
#define URI_ASSERT_BADPATH(uri) CPPUNIT_ASSERT(!wxURI(uri).HasPath())
|
||||||
|
// IPv4
|
||||||
|
#define URI_ASSERT_IPV4_TEST(ip, expected) \
|
||||||
|
URI_ASSERT_HOST_TEST("http://user:password@" ip ":5050/path", expected, wxURI_IPV4ADDRESS)
|
||||||
|
#define URI_ASSERT_IPV4_TESTBAD(ip) \
|
||||||
|
URI_ASSERT_HOST_TESTBAD("http://user:password@" ip ":5050/path", wxURI_IPV4ADDRESS)
|
||||||
|
// IPv6
|
||||||
|
#define URI_ASSERT_IPV6_TEST(ip, expected) \
|
||||||
|
URI_ASSERT_HOST_TEST("http://user:password@" ip ":5050/path", expected, wxURI_IPV6ADDRESS)
|
||||||
|
#define URI_ASSERT_IPV6_TESTBAD(ip) \
|
||||||
|
URI_ASSERT_HOST_TESTBAD("http://user:password@" ip ":5050/path", wxURI_IPV6ADDRESS)
|
||||||
|
// Resolve
|
||||||
|
#define URI_TEST_RESOLVE_IMPL(string, eq, strictness) \
|
||||||
|
{\
|
||||||
|
wxURI uri(string); \
|
||||||
|
uri.Resolve(masteruri, strictness); \
|
||||||
|
CPPUNIT_ASSERT_EQUAL(eq, uri.BuildURI()); \
|
||||||
|
}
|
||||||
|
#define URI_TEST_RESOLVE(string, eq) \
|
||||||
|
URI_TEST_RESOLVE_IMPL(string, eq, wxURI_STRICT);
|
||||||
|
#define URI_TEST_RESOLVE_LAX(string, eq) \
|
||||||
|
URI_TEST_RESOLVE_IMPL(string, eq, 0);
|
||||||
|
|
||||||
|
// Normalization
|
||||||
|
#define URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL(uri, expected) \
|
||||||
|
{ wxURI nuri(uri); nuri.Resolve(wxURI("http://a/"));\
|
||||||
|
CPPUNIT_ASSERT_EQUAL(expected, nuri.GetPath()); }
|
||||||
|
#define URI_ASSERT_NORMALIZEDPATH_EQUAL(uri, expected) \
|
||||||
|
{ URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL(uri, expected); }
|
||||||
|
|
||||||
void URITestCase::IPv4()
|
void URITestCase::IPv4()
|
||||||
{
|
{
|
||||||
|
URI_ASSERT_IPV4_TEST("192.168.1.100", "192.168.1.100");
|
||||||
|
URI_ASSERT_IPV4_TEST("192.255.1.100", "192.255.1.100");
|
||||||
|
URI_ASSERT_IPV4_TEST("192.0.2.16", "192.0.2.16");
|
||||||
|
URI_ASSERT_IPV4_TEST("255.0.0.0", "255.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TEST("0.0.0.0", "0.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TEST("1.0.0.0", "1.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TEST("2.0.0.0", "2.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TEST("3.0.0.0", "3.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TEST("30.0.0.0", "30.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("192.256.1.100");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("01.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("001.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("00.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("000.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("256.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("300.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("1111.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("-1.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("0.0.0.");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("0.0.0.0.");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("0.0.0.0.0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD("0.0..0");
|
||||||
|
URI_ASSERT_IPV4_TESTBAD(".0.0.0");
|
||||||
URI_ASSERT_HOSTTYPE_EQUAL("http://user:password@192.168.1.100:5050/path",
|
URI_ASSERT_HOSTTYPE_EQUAL("http://user:password@192.168.1.100:5050/path",
|
||||||
wxURI_IPV4ADDRESS);
|
wxURI_IPV4ADDRESS);
|
||||||
|
|
||||||
URI_ASSERT_HOSTTYPE_EQUAL("http://user:password@192.255.1.100:5050/path",
|
URI_ASSERT_HOSTTYPE_EQUAL("http://user:password@192.255.1.100:5050/path",
|
||||||
wxURI_IPV4ADDRESS);
|
wxURI_IPV4ADDRESS);
|
||||||
|
|
||||||
// bogus ipv4
|
// bogus ipv4
|
||||||
CPPUNIT_ASSERT( wxURI("http://user:password@192.256.1.100:5050/path").
|
CPPUNIT_ASSERT( wxURI("http://user:password@192.256.1.100:5050/path").
|
||||||
GetHostType() != wxURI_IPV4ADDRESS);
|
GetHostType() != wxURI_IPV4ADDRESS);
|
||||||
|
|
@ -122,170 +173,199 @@ void URITestCase::IPv4()
|
||||||
|
|
||||||
void URITestCase::IPv6()
|
void URITestCase::IPv6()
|
||||||
{
|
{
|
||||||
// IPv6address = 6( h16 ":" ) ls32
|
|
||||||
// / "::" 5( h16 ":" ) ls32
|
|
||||||
// / [ h16 ] "::" 4( h16 ":" ) ls32
|
|
||||||
// / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
|
|
||||||
// / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
|
|
||||||
// / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
|
|
||||||
// / [ *4( h16 ":" ) h16 ] "::" ls32
|
|
||||||
// / [ *5( h16 ":" ) h16 ] "::" h16
|
|
||||||
// / [ *6( h16 ":" ) h16 ] "::"
|
|
||||||
// ls32 = ( h16 ":" h16 ) / IPv4address
|
|
||||||
|
|
||||||
URI_ASSERT_HOSTTYPE_EQUAL
|
URI_ASSERT_HOSTTYPE_EQUAL
|
||||||
(
|
(
|
||||||
"http://user:password@[aa:aa:aa:aa:aa:aa:192.168.1.100]:5050/path",
|
"http://user:password@[aa:aa:aa:aa:aa:aa:192.168.1.100]:5050/path",
|
||||||
wxURI_IPV6ADDRESS
|
wxURI_IPV6ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
URI_ASSERT_HOSTTYPE_EQUAL
|
URI_ASSERT_HOSTTYPE_EQUAL
|
||||||
(
|
(
|
||||||
"http://user:password@[aa:aa:aa:aa:aa:aa:aa:aa]:5050/path",
|
"http://user:password@[aa:aa:aa:aa:aa:aa:aa:aa]:5050/path",
|
||||||
wxURI_IPV6ADDRESS
|
wxURI_IPV6ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
URI_ASSERT_HOSTTYPE_EQUAL
|
URI_ASSERT_HOSTTYPE_EQUAL
|
||||||
(
|
(
|
||||||
"http://user:password@[aa:aa:aa:aa::192.168.1.100]:5050/path",
|
"http://user:password@[aa:aa:aa:aa::192.168.1.100]:5050/path",
|
||||||
wxURI_IPV6ADDRESS
|
wxURI_IPV6ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
URI_ASSERT_HOSTTYPE_EQUAL
|
URI_ASSERT_HOSTTYPE_EQUAL
|
||||||
(
|
(
|
||||||
"http://user:password@[aa:aa:aa:aa::aa:aa]:5050/path",
|
"http://user:password@[aa:aa:aa:aa::aa:aa]:5050/path",
|
||||||
wxURI_IPV6ADDRESS
|
wxURI_IPV6ADDRESS
|
||||||
);
|
);
|
||||||
|
URI_ASSERT_IPV6_TEST("[aa:aa:aa:aa:aa:aa:192.168.1.100]", "aa:aa:aa:aa:aa:aa:192.168.1.100");
|
||||||
|
URI_ASSERT_IPV6_TEST("[aa:aa:aa:aa:aa:aa:aa:aa]", "aa:aa:aa:aa:aa:aa:aa:aa");
|
||||||
|
URI_ASSERT_IPV6_TEST("[aa:aa:aa:aa::192.168.1.100]", "aa:aa:aa:aa::192.168.1.100");
|
||||||
|
URI_ASSERT_IPV6_TEST("[aa:aa:aa:aa::aa:aa]", "aa:aa:aa:aa::aa:aa");
|
||||||
|
URI_ASSERT_IPV6_TEST("[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1080:0:0:0:8:800:200C:417A]", "1080:0:0:0:8:800:200C:417A");
|
||||||
|
URI_ASSERT_IPV6_TEST("[3ffe:2a00:100:7031::1]", "3ffe:2a00:100:7031::1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1080::8:800:200C:417A]", "1080::8:800:200C:417A");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::192.9.5.5]", "::192.9.5.5");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::FFFF:129.144.52.38]", "::FFFF:129.144.52.38");
|
||||||
|
URI_ASSERT_IPV6_TEST("[2010:836B:4179::836B:4179]", "2010:836B:4179::836B:4179");
|
||||||
|
URI_ASSERT_IPV6_TEST("[abcd::]", "abcd::");
|
||||||
|
URI_ASSERT_IPV6_TEST("[abcd::1]", "abcd::1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[abcd::12]", "abcd::12");
|
||||||
|
URI_ASSERT_IPV6_TEST("[abcd::123]", "abcd::123");
|
||||||
|
URI_ASSERT_IPV6_TEST("[abcd::1234]", "abcd::1234");
|
||||||
|
URI_ASSERT_IPV6_TEST("[2001:0db8:0100:f101:0210:a4ff:fee3:9566]", "2001:0db8:0100:f101:0210:a4ff:fee3:9566");
|
||||||
|
URI_ASSERT_IPV6_TEST("[2001:0DB8:0100:F101:0210:A4FF:FEE3:9566]", "2001:0DB8:0100:F101:0210:A4FF:FEE3:9566");
|
||||||
|
URI_ASSERT_IPV6_TEST("[2001:db8:100:f101:210:a4ff:fee3:9566]", "2001:db8:100:f101:210:a4ff:fee3:9566");
|
||||||
|
URI_ASSERT_IPV6_TEST("[2001:0db8:100:f101:0:0:0:1]","2001:0db8:100:f101:0:0:0:1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:2:3:4:5:6:255.255.255.255]","1:2:3:4:5:6:255.255.255.255");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::1.2.3.4]", "::1.2.3.4");
|
||||||
|
URI_ASSERT_IPV6_TEST("[3:4::5:1.2.3.4]", "3:4::5:1.2.3.4");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::ffff:1.2.3.4]", "::ffff:1.2.3.4");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::0.0.0.0]", "::0.0.0.0");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::255.255.255.255]", "::255.255.255.255");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::1:2:3:4:5:6:7]", "::1:2:3:4:5:6:7");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1::1:2:3:4:5:6]", "1::1:2:3:4:5:6");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:2::1:2:3:4:5]", "1:2::1:2:3:4:5");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:2:3::1:2:3:4]", "1:2:3::1:2:3:4");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:2:3:4::1:2:3]", "1:2:3:4::1:2:3");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:2:3:4:5::1:2]", "1:2:3:4:5::1:2");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:2:3:4:5:6::1]", "1:2:3:4:5:6::1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:2:3:4:5:6:7::]", "1:2:3:4:5:6:7::");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:1:1::1:1:1:1]", "1:1:1::1:1:1:1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:1:1::1:1:1]", "1:1:1::1:1:1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:1:1::1:1]", "1:1:1::1:1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:1::1:1]", "1:1::1:1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1:1::1]", "1:1::1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[1::1]", "1::1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::1]", "::1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[::]", "::");
|
||||||
|
URI_ASSERT_IPV6_TEST("[21ff:abcd::1]", "21ff:abcd::1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[2001:db8:100:f101::1]", "2001:db8:100:f101::1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[a:b:c::12:1]", "a:b:c::12:1");
|
||||||
|
URI_ASSERT_IPV6_TEST("[a:b::0:1:2:3]", "a:b::0:1:2:3");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::12345]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[abcd::abcd::abcd]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[:::1234]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[1234:::1234:1234]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[1234:1234:::1234]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[1234:::]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[1.2.3.4]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[0001.0002.0003.0004]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[0000:0000:0000:0000:0000:1.2.3.4]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[0:0:0:0:0:0:0]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[0:0:0:0:0:0:0:]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[0:0:0:0:0:0:0:1.2.3.4]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[0:0:0:0:0:0:0:0:0]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:001.02.03.004]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:1.2.3.1111]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:1.2.3.256]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:311.2.3.4]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:1.2.3:4]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:1.2.3]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:1.2.3.]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:1.2.3a.4]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[::ffff:1.2.3.4:123]");
|
||||||
|
URI_ASSERT_IPV6_TESTBAD("[g:0:0:0:0:0:0]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void URITestCase::Server()
|
void URITestCase::Host()
|
||||||
{
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/../path",
|
|
||||||
"/path");
|
|
||||||
|
|
||||||
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/.",
|
|
||||||
"/path/");
|
|
||||||
|
|
||||||
URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/path/./",
|
|
||||||
"/path/");
|
|
||||||
|
|
||||||
URI_ASSERT_PART_EQUAL("path/john/../../../joe",
|
|
||||||
"../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()
|
|
||||||
{
|
{
|
||||||
|
URI_ASSERT_HOST_EQUAL("", "");
|
||||||
|
URI_ASSERT_HOST_EQUAL("http://foo/", "foo");
|
||||||
|
URI_ASSERT_HOST_EQUAL("http://foo-bar/", "foo-bar");
|
||||||
|
URI_ASSERT_HOST_EQUAL("http://foo/bar/", "foo");
|
||||||
|
URI_ASSERT_HOST_EQUAL("http://192.168.1.0/", "192.168.1.0");
|
||||||
|
URI_ASSERT_HOST_EQUAL("http://192.168.1.17/", "192.168.1.17");
|
||||||
|
URI_ASSERT_HOST_EQUAL("http://192.168.1.255/", "192.168.1.255");
|
||||||
|
URI_ASSERT_HOST_EQUAL("http://192.168.1.1/index.html", "192.168.1.1");
|
||||||
|
URI_ASSERT_HOST_EQUAL("http://[aa:aa:aa:aa::aa:aa]/foo", "aa:aa:aa:aa::aa:aa");
|
||||||
URI_ASSERT_USER_EQUAL("http://user:pass@host/path/", "user");
|
URI_ASSERT_USER_EQUAL("http://user:pass@host/path/", "user");
|
||||||
URI_ASSERT_USER_EQUAL("http://user@host/path/", "user");
|
URI_ASSERT_USER_EQUAL("http://user@host/path/", "user");
|
||||||
URI_ASSERT_USER_EQUAL("http://host/path/", "");
|
URI_ASSERT_USER_EQUAL("http://host/path/", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#define URI_TEST_RESOLVE_IMPL(string, eq, strict) \
|
void URITestCase::Paths()
|
||||||
{ \
|
{
|
||||||
wxURI uri(string); \
|
try
|
||||||
uri.Resolve(masteruri, strict); \
|
{
|
||||||
CPPUNIT_ASSERT_EQUAL(eq, uri.BuildURI()); \
|
wxURI test("http://user:password@192.256.1.100:5050/../path");
|
||||||
|
wxString sTest = test.BuildURI(); // This isn't a unit test, just a niche parsing crash test
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
#define URI_TEST_RESOLVE(string, eq) \
|
{
|
||||||
URI_TEST_RESOLVE_IMPL(string, eq, true);
|
CPPUNIT_ASSERT(false);
|
||||||
|
}
|
||||||
#define URI_TEST_RESOLVE_LAX(string, eq) \
|
URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/../path", "/../path");
|
||||||
URI_TEST_RESOLVE_IMPL(string, eq, false);
|
URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/path/../", "/path/../");
|
||||||
|
URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/path/.", "/path/.");
|
||||||
|
URI_ASSERT_PATH_EQUAL("http://user:password@192.256.1.100:5050/path/./", "/path/./");
|
||||||
|
URI_ASSERT_PART_EQUAL("path/john/../../../joe", "path/john/../../../joe", BuildURI());
|
||||||
|
//When authority is present, the path must either be empty or begin with a slash ("/") character.
|
||||||
|
URI_ASSERT_BADPATH("http://good.com:8042BADPATH");
|
||||||
|
URI_ASSERT_PATH_EQUAL("http://good.com:8042/GOODPATH", "/GOODPATH");
|
||||||
|
//When authority is not present, the path cannot begin with two slash characters ("//").
|
||||||
|
URI_ASSERT_BADPATH("http:////BADPATH");
|
||||||
|
}
|
||||||
|
|
||||||
//examples taken from RFC 2396.bis
|
//examples taken from RFC 2396.bis
|
||||||
|
|
||||||
void URITestCase::NormalResolving()
|
void URITestCase::NormalResolving()
|
||||||
{
|
{
|
||||||
wxURI masteruri("http://a/b/c/d;p?q");
|
wxURI masteruri("http://a/b/c/d;p?q");
|
||||||
|
URI_TEST_RESOLVE("g:h" ,"g:h")
|
||||||
URI_TEST_RESOLVE("g:h" ,"g:h")
|
URI_TEST_RESOLVE("g" ,"http://a/b/c/g")
|
||||||
URI_TEST_RESOLVE("g" ,"http://a/b/c/g")
|
URI_TEST_RESOLVE("./g" ,"http://a/b/c/g")
|
||||||
URI_TEST_RESOLVE("./g" ,"http://a/b/c/g")
|
URI_TEST_RESOLVE("g/" ,"http://a/b/c/g/")
|
||||||
URI_TEST_RESOLVE("g/" ,"http://a/b/c/g/")
|
URI_TEST_RESOLVE("/g" ,"http://a/g")
|
||||||
URI_TEST_RESOLVE("/g" ,"http://a/g")
|
URI_TEST_RESOLVE("//g" ,"http://g")
|
||||||
URI_TEST_RESOLVE("//g" ,"http://g")
|
URI_TEST_RESOLVE("?y" ,"http://a/b/c/d;p?y")
|
||||||
URI_TEST_RESOLVE("?y" ,"http://a/b/c/d;p?y")
|
URI_TEST_RESOLVE("g?y" ,"http://a/b/c/g?y")
|
||||||
URI_TEST_RESOLVE("g?y" ,"http://a/b/c/g?y")
|
URI_TEST_RESOLVE("#s" ,"http://a/b/c/d;p?q#s")
|
||||||
URI_TEST_RESOLVE("#s" ,"http://a/b/c/d;p?q#s")
|
URI_TEST_RESOLVE("g#s" ,"http://a/b/c/g#s")
|
||||||
URI_TEST_RESOLVE("g#s" ,"http://a/b/c/g#s")
|
|
||||||
URI_TEST_RESOLVE("g?y#s","http://a/b/c/g?y#s")
|
URI_TEST_RESOLVE("g?y#s","http://a/b/c/g?y#s")
|
||||||
URI_TEST_RESOLVE(";x" ,"http://a/b/c/;x")
|
URI_TEST_RESOLVE(";x" ,"http://a/b/c/;x")
|
||||||
URI_TEST_RESOLVE("g;x" ,"http://a/b/c/g;x")
|
URI_TEST_RESOLVE("g;x" ,"http://a/b/c/g;x")
|
||||||
URI_TEST_RESOLVE("g;x?y#s","http://a/b/c/g;x?y#s")
|
URI_TEST_RESOLVE("g;x?y#s","http://a/b/c/g;x?y#s")
|
||||||
|
URI_TEST_RESOLVE("" ,"http://a/b/c/d;p?q")
|
||||||
URI_TEST_RESOLVE("" ,"http://a/b/c/d;p?q")
|
URI_TEST_RESOLVE("." ,"http://a/b/c/")
|
||||||
URI_TEST_RESOLVE("." ,"http://a/b/c/")
|
URI_TEST_RESOLVE("./" ,"http://a/b/c/")
|
||||||
URI_TEST_RESOLVE("./" ,"http://a/b/c/")
|
URI_TEST_RESOLVE(".." ,"http://a/b/")
|
||||||
URI_TEST_RESOLVE(".." ,"http://a/b/")
|
URI_TEST_RESOLVE("../" ,"http://a/b/")
|
||||||
URI_TEST_RESOLVE("../" ,"http://a/b/")
|
|
||||||
URI_TEST_RESOLVE("../g" ,"http://a/b/g")
|
URI_TEST_RESOLVE("../g" ,"http://a/b/g")
|
||||||
URI_TEST_RESOLVE("../..","http://a/")
|
URI_TEST_RESOLVE("../..","http://a/")
|
||||||
URI_TEST_RESOLVE("../../" , "http://a/")
|
URI_TEST_RESOLVE("../../" , "http://a/")
|
||||||
URI_TEST_RESOLVE("../../g" , "http://a/g")
|
URI_TEST_RESOLVE("../../g" , "http://a/g")
|
||||||
}
|
}
|
||||||
|
|
||||||
void URITestCase::ComplexResolving()
|
void URITestCase::ComplexResolving()
|
||||||
{
|
{
|
||||||
wxURI masteruri("http://a/b/c/d;p?q");
|
wxURI masteruri("http://a/b/c/d;p?q");
|
||||||
|
URI_TEST_RESOLVE("../../../g" , "http://a/g")
|
||||||
//odd path examples
|
|
||||||
URI_TEST_RESOLVE("../../../g" , "http://a/g")
|
|
||||||
URI_TEST_RESOLVE("../../../../g", "http://a/g")
|
URI_TEST_RESOLVE("../../../../g", "http://a/g")
|
||||||
|
URI_TEST_RESOLVE("/./g" ,"http://a/g")
|
||||||
URI_TEST_RESOLVE("/./g" ,"http://a/g")
|
|
||||||
URI_TEST_RESOLVE("/../g" ,"http://a/g")
|
URI_TEST_RESOLVE("/../g" ,"http://a/g")
|
||||||
URI_TEST_RESOLVE("g." ,"http://a/b/c/g.")
|
URI_TEST_RESOLVE("g." ,"http://a/b/c/g.")
|
||||||
URI_TEST_RESOLVE(".g" ,"http://a/b/c/.g")
|
URI_TEST_RESOLVE(".g" ,"http://a/b/c/.g")
|
||||||
URI_TEST_RESOLVE("g.." ,"http://a/b/c/g..")
|
URI_TEST_RESOLVE("g.." ,"http://a/b/c/g..")
|
||||||
URI_TEST_RESOLVE("..g" ,"http://a/b/c/..g")
|
URI_TEST_RESOLVE("..g" ,"http://a/b/c/..g")
|
||||||
|
// github issue #3350
|
||||||
|
masteruri = "file:doc.chm#xchm:/d/e";
|
||||||
|
URI_TEST_RESOLVE("/a/b/c.jpg" ,"file://doc.chm/a/b/c.jpg")
|
||||||
}
|
}
|
||||||
|
|
||||||
void URITestCase::ReallyComplexResolving()
|
void URITestCase::ReallyComplexResolving()
|
||||||
{
|
{
|
||||||
wxURI masteruri("http://a/b/c/d;p?q");
|
wxURI masteruri("http://a/b/c/d;p?q");
|
||||||
|
URI_TEST_RESOLVE("./../g" ,"http://a/b/g")
|
||||||
//even more odder path examples
|
URI_TEST_RESOLVE("./g/." ,"http://a/b/c/g/")
|
||||||
URI_TEST_RESOLVE("./../g" ,"http://a/b/g")
|
URI_TEST_RESOLVE("g/./h" ,"http://a/b/c/g/h")
|
||||||
URI_TEST_RESOLVE("./g/." ,"http://a/b/c/g/")
|
URI_TEST_RESOLVE("g/../h" ,"http://a/b/c/h")
|
||||||
URI_TEST_RESOLVE("g/./h" ,"http://a/b/c/g/h")
|
URI_TEST_RESOLVE("g;x=1/./y" ,"http://a/b/c/g;x=1/y")
|
||||||
URI_TEST_RESOLVE("g/../h" ,"http://a/b/c/h")
|
URI_TEST_RESOLVE("g;x=1/../y" ,"http://a/b/c/y")
|
||||||
URI_TEST_RESOLVE("g;x=1/./y" , "http://a/b/c/g;x=1/y")
|
|
||||||
URI_TEST_RESOLVE("g;x=1/../y" , "http://a/b/c/y")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void URITestCase::QueryFragmentResolving()
|
void URITestCase::QueryFragmentResolving()
|
||||||
{
|
{
|
||||||
wxURI masteruri("http://a/b/c/d;p?q");
|
wxURI masteruri("http://a/b/c/d;p?q"); //query/fragment ambigiousness
|
||||||
|
URI_TEST_RESOLVE("g?y/./x", "http://a/b/c/g?y/./x")
|
||||||
//query/fragment ambigiousness
|
URI_TEST_RESOLVE("g?y/../x", "http://a/b/c/g?y/../x")
|
||||||
URI_TEST_RESOLVE("g?y/./x","http://a/b/c/g?y/./x")
|
URI_TEST_RESOLVE("g#s/./x", "http://a/b/c/g#s/./x")
|
||||||
URI_TEST_RESOLVE("g?y/../x" , "http://a/b/c/g?y/../x")
|
URI_TEST_RESOLVE("g#s/../x", "http://a/b/c/g#s/../x")
|
||||||
URI_TEST_RESOLVE("g#s/./x","http://a/b/c/g#s/./x")
|
|
||||||
URI_TEST_RESOLVE("g#s/../x" , "http://a/b/c/g#s/../x")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void URITestCase::BackwardsResolving()
|
void URITestCase::BackwardsResolving()
|
||||||
|
|
@ -350,6 +430,12 @@ void URITestCase::Unescaping()
|
||||||
L"file://\u043C\u043E\u0439\\\u0444\u0430\u0439\u043B",
|
L"file://\u043C\u043E\u0439\\\u0444\u0430\u0439\u043B",
|
||||||
unescaped
|
unescaped
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
escaped = "%2FH%C3%A4ll%C3%B6%5C";
|
||||||
|
unescaped = wxURI(escaped).BuildUnescapedURI();
|
||||||
|
CPPUNIT_ASSERT_EQUAL(wxString::FromUTF8("\x2FH\xC3\xA4ll\xC3\xB6\x5C"),
|
||||||
|
unescaped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void URITestCase::FileScheme()
|
void URITestCase::FileScheme()
|
||||||
|
|
@ -440,8 +526,48 @@ void URITestCase::URLCompat()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// the purpose of this test is unclear, it seems to be unfinished so disabling
|
void URITestCase::Normalizing()
|
||||||
// it for now
|
{
|
||||||
|
#if 0 // NB: wxURI doesn't have dedicated normalization support yet
|
||||||
|
//5.2.4 #2 remove dot segments
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("./", ""); //A
|
||||||
|
wxURI ss("./");
|
||||||
|
ss.Resolve(wxURI("http://a.com/"));
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("/./", "/"); //B
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("/.", "/"); //B2
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("/../", "/"); //C
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("/..", "/"); //C2
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL(".", ""); //D
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("../", ""); //A2
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("..", ""); //D2
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("../../../", ""); //A2 complex
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("../..", ""); //A2+D2 complex
|
||||||
|
//5.2.4 in practice
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("path/john/../../../joe", "joe");
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("http://user:password@192.256.1.100:5050/../path", "/path");
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("http://user:password@192.256.1.100:5050/path/../", "/");
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("http://user:password@192.256.1.100:5050/path/.", "/path/");
|
||||||
|
URI_ASSERT_NORMALIZEDPATH_EQUAL("http://user:password@192.256.1.100:5050/path/./", "/path/");
|
||||||
|
// hexdigit normalizing
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%aA", "%AA");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%Aa", "%AA");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%aa", "%AA");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%AA", "%AA");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%Af", "%AF");
|
||||||
|
//Alpha/Digit/'-'/'.'/'_'/'~'
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%42", "B");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%30", "0");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%2D", "-");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%2E", ".");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%5F", "_");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%7E", "~");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%42%30%2D%2E%5F%7E", "B0-._~");
|
||||||
|
URI_ASSERT_NORMALIZEDENCODEDPATH_EQUAL("%F1%42%30%2D%Fa%2E%5F%7E%F1", "%F1B0-%FA._~%F1");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is for testing routing through a proxy with wxURL, it's a little niche
|
||||||
|
// and requires a specific setup.
|
||||||
#if 0 && wxUSE_PROTOCOL_HTTP
|
#if 0 && wxUSE_PROTOCOL_HTTP
|
||||||
void URITestCase::URLProxy()
|
void URITestCase::URLProxy()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue