{
// pct-encoded = "%" HEXDIG HEXDIG
if(*uri == wxT('%') && IsHex(*(uri+1)) && IsHex(*(uri+2)))
- {
- uri += 3;
return true;
- }
else
return false;
}
// 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++);
}
CPPUNIT_TEST( BackwardsResolving );
CPPUNIT_TEST( Assignment );
CPPUNIT_TEST( Comparison );
+ CPPUNIT_TEST( Unescaping );
#if TEST_URL
CPPUNIT_TEST( URLCompat );
#if wxUSE_PROTOCOL_HTTP
void BackwardsResolving();
void Assignment();
void Comparison();
+ void Unescaping();
#if TEST_URL
void URLCompat();
CPPUNIT_ASSERT(wxURI(wxT("http://mysite.com")) == wxURI(wxT("http://mysite.com")));
}
+void URITestCase::Unescaping()
+{
+ wxString orig = wxT("http://test.com/of/file%3A%2F%2FC%3A%5Curi%5C")
+ wxT("escaping%5Cthat%5Cseems%5Cbroken%5Csadly%5B1%5D.rss");
+
+ wxString works= wxURI(orig).BuildUnescapedURI();
+
+ CPPUNIT_ASSERT(orig.IsSameAs(works) == false);
+
+ wxString orig2 = wxT("http://test.com/of/file%3A%2F%")
+ wxT("2FC%3A%5Curi%5Cescaping%5Cthat%5Cseems%")
+ wxT("5Cbroken%5Csadly%5B1%5D.rss");
+
+ wxString works2 = wxURI::Unescape(orig2);
+ wxString broken2 = wxURI(orig2).BuildUnescapedURI();
+
+ CPPUNIT_ASSERT(works2.IsSameAs(broken2));
+
+}
+
#if TEST_URL
#include "wx/url.h"
+#include "wx/file.h"
void URITestCase::URLCompat()
{
url.SetProxy(wxT("pserv:3122"));
}
#endif // wxUSE_PROTOCOL_HTTP
-#endif
+
+#endif // TEST_URL