X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4860d40db4a78d8c2fd20d0b7b75136d749050eb..b9efe021b554fa3967d1442cf758435c5cd5ae8f:/src/common/uri.cpp diff --git a/src/common/uri.cpp b/src/common/uri.cpp index 0f03cf5aa5..5c5a643ba1 100644 --- a/src/common/uri.cpp +++ b/src/common/uri.cpp @@ -115,10 +115,9 @@ const wxChar* wxURI::Create(const wxString& uri) 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) @@ -151,10 +150,7 @@ bool wxURI::IsEscape(const wxChar*& uri) { // pct-encoded = "%" HEXDIG HEXDIG if(*uri == wxT('%') && IsHex(*(uri+1)) && IsHex(*(uri+2))) - { - uri += 3; return true; - } else return false; } @@ -376,7 +372,7 @@ bool wxURI::IsReference() const // 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) @@ -461,9 +457,15 @@ const wxChar* wxURI::ParseUserInfo(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++); } @@ -541,8 +543,14 @@ const wxChar* wxURI::ParseServer(const wxChar* 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++); } @@ -611,9 +619,15 @@ const wxChar* wxURI::ParsePath(const wxChar* uri, bool bReference, bool bNormali 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++); } @@ -637,9 +651,15 @@ const wxChar* wxURI::ParsePath(const wxChar* uri, bool bReference, bool bNormali //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++); } @@ -648,9 +668,15 @@ const wxChar* wxURI::ParsePath(const wxChar* uri, bool bReference, bool bNormali { 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++); } @@ -687,9 +713,15 @@ const wxChar* wxURI::ParseQuery(const wxChar* 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++); } @@ -712,9 +744,15 @@ const wxChar* wxURI::ParseFragment(const wxChar* 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++); }