wxChar wxURI::TranslateEscape(const wxChar* s)
{
- wxASSERT_MSG(IsHex(*s) && IsHex(*(s+1)), wxT("Invalid escape!"));
+ wxASSERT_MSG( IsHex(s[0]) && IsHex(s[1]), wxT("Invalid escape sequence!"));
- //<<4 == 16
- return (wxChar)( CharToHex(*s) << 4 ) | CharToHex(*++s);
+ return (wxChar)( CharToHex(s[0]) << 4 ) | CharToHex(s[1]);
}
wxString wxURI::Unescape(const wxString& uri)
{
// pct-encoded = "%" HEXDIG HEXDIG
if(*uri == wxT('%') && IsHex(*(uri+1)) && IsHex(*(uri+2)))
- {
- uri += 3;
return true;
- }
else
return false;
}
// Master URI parsing method. Just calls the individual parsing methods
//
// URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
-// URI-reference = URI / relative-URITestCase
+// URI-reference = URI / relative
// ---------------------------------------------------------------------------
const wxChar* wxURI::Parse(const wxChar* uri)
// userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
while(*uri && *uri != wxT('@') && *uri != wxT('/') && *uri != wxT('#') && *uri != wxT('?'))
{
- if(IsUnreserved(*uri) || IsEscape(uri) ||
+ if(IsUnreserved(*uri) ||
IsSubDelim(*uri) || *uri == wxT(':'))
m_userinfo += *uri++;
+ else if (IsEscape(uri))
+ {
+ m_userinfo += *uri++;
+ m_userinfo += *uri++;
+ m_userinfo += *uri++;
+ }
else
Escape(m_userinfo, *uri++);
}
// reg-name = *( unreserved / pct-encoded / sub-delims )
while(*uri && *uri != wxT('/') && *uri != wxT(':') && *uri != wxT('#') && *uri != wxT('?'))
{
- if(IsUnreserved(*uri) || IsEscape(uri) || IsSubDelim(*uri))
+ if(IsUnreserved(*uri) || IsSubDelim(*uri))
+ m_server += *uri++;
+ else if (IsEscape(uri))
+ {
m_server += *uri++;
+ m_server += *uri++;
+ m_server += *uri++;
+ }
else
Escape(m_server, *uri++);
}
while(*uri && *uri != wxT('#') && *uri != wxT('?'))
{
- if( IsUnreserved(*uri) || IsSubDelim(*uri) || IsEscape(uri) ||
+ if( IsUnreserved(*uri) || IsSubDelim(*uri) ||
*uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/'))
m_path += *uri++;
+ else if (IsEscape(uri))
+ {
+ m_path += *uri++;
+ m_path += *uri++;
+ m_path += *uri++;
+ }
else
Escape(m_path, *uri++);
}
//no colon allowed
while(*uri && *uri != wxT('#') && *uri != wxT('?'))
{
- if(IsUnreserved(*uri) || IsSubDelim(*uri) || IsEscape(uri) ||
+ if(IsUnreserved(*uri) || IsSubDelim(*uri) ||
*uri == wxT('@') || *uri == wxT('/'))
m_path += *uri++;
+ else if (IsEscape(uri))
+ {
+ m_path += *uri++;
+ m_path += *uri++;
+ m_path += *uri++;
+ }
else
Escape(m_path, *uri++);
}
{
while(*uri && *uri != wxT('#') && *uri != wxT('?'))
{
- if(IsUnreserved(*uri) || IsSubDelim(*uri) || IsEscape(uri) ||
+ if(IsUnreserved(*uri) || IsSubDelim(*uri) ||
*uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/'))
m_path += *uri++;
+ else if (IsEscape(uri))
+ {
+ m_path += *uri++;
+ m_path += *uri++;
+ m_path += *uri++;
+ }
else
Escape(m_path, *uri++);
}
++uri;
while(*uri && *uri != wxT('#'))
{
- if (IsUnreserved(*uri) || IsSubDelim(*uri) || IsEscape(uri) ||
+ if (IsUnreserved(*uri) || IsSubDelim(*uri) ||
*uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/') || *uri == wxT('?'))
m_query += *uri++;
+ else if (IsEscape(uri))
+ {
+ m_query += *uri++;
+ m_query += *uri++;
+ m_query += *uri++;
+ }
else
Escape(m_query, *uri++);
}
++uri;
while(*uri)
{
- if (IsUnreserved(*uri) || IsSubDelim(*uri) || IsEscape(uri) ||
+ if (IsUnreserved(*uri) || IsSubDelim(*uri) ||
*uri == wxT(':') || *uri == wxT('@') || *uri == wxT('/') || *uri == wxT('?'))
m_fragment += *uri++;
+ else if (IsEscape(uri))
+ {
+ m_fragment += *uri++;
+ m_fragment += *uri++;
+ m_fragment += *uri++;
+ }
else
Escape(m_fragment, *uri++);
}