A couple of changes related to the way that URLs are parsed to form
a valid URI in the wxURL::ConvertToValidURI function. Modified to comply with RFC2396 as much as possible, see comments in the code. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7084 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
// Copyright: (c) 1997, 1998 Guilhem Lavaux
|
// Copyright: (c) 1997, 1998 Guilhem Lavaux
|
||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_URL_H
|
#ifndef _WX_URL_H
|
||||||
#define _WX_URL_H
|
#define _WX_URL_H
|
||||||
|
|
||||||
@@ -55,7 +56,10 @@ public:
|
|||||||
void SetProxy(const wxString& url_proxy);
|
void SetProxy(const wxString& url_proxy);
|
||||||
#endif // wxUSE_SOCKETS
|
#endif // wxUSE_SOCKETS
|
||||||
|
|
||||||
static wxString ConvertToValidURI(const wxString& uri);
|
static wxString ConvertToValidURI(
|
||||||
|
const wxString& uri,
|
||||||
|
const wxChar* delims = wxT(";/?:@&=+$,")
|
||||||
|
);
|
||||||
static wxString ConvertFromURI(const wxString& uri);
|
static wxString ConvertFromURI(const wxString& uri);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -398,7 +398,7 @@ void wxURL::SetProxy(const wxString& url_proxy)
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_SOCKETS
|
#endif // wxUSE_SOCKETS
|
||||||
|
|
||||||
wxString wxURL::ConvertToValidURI(const wxString& uri)
|
wxString wxURL::ConvertToValidURI(const wxString& uri, const wxChar* delims)
|
||||||
{
|
{
|
||||||
wxString out_str;
|
wxString out_str;
|
||||||
wxString hexa_code;
|
wxString hexa_code;
|
||||||
@@ -410,11 +410,25 @@ wxString wxURL::ConvertToValidURI(const wxString& uri)
|
|||||||
|
|
||||||
if (c == wxT(' '))
|
if (c == wxT(' '))
|
||||||
{
|
{
|
||||||
out_str += wxT('+');
|
// GRG, Apr/2000: changed to "%20" instead of '+'
|
||||||
|
|
||||||
|
out_str += wxT("%20");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!wxIsalnum(c) && c != wxT('.') && c != wxT('+') && c != wxT('/'))
|
// GRG, Apr/2000: modified according to the URI definition (RFC 2396)
|
||||||
|
//
|
||||||
|
// - Alphanumeric characters are never escaped
|
||||||
|
// - Unreserved marks are never escaped
|
||||||
|
// - Delimiters must be escaped if they appear within a component
|
||||||
|
// but not if they are used to separate components. Here we have
|
||||||
|
// no clear way to distinguish between these two cases, so they
|
||||||
|
// are escaped unless they are passed in the 'delims' parameter
|
||||||
|
// (allowed delimiters).
|
||||||
|
|
||||||
|
static const wxChar marks[] = wxT("-_.!~*()'");
|
||||||
|
|
||||||
|
if ( !wxIsalnum(c) && !wxStrchr(marks, c) && !wxStrchr(delims, c) )
|
||||||
{
|
{
|
||||||
hexa_code.Printf(wxT("%%%02X"), c);
|
hexa_code.Printf(wxT("%%%02X"), c);
|
||||||
out_str += hexa_code;
|
out_str += hexa_code;
|
||||||
@@ -485,6 +499,7 @@ bool wxURLModule::OnInit()
|
|||||||
// set, but don't try to create this proxy right now because it will slow
|
// set, but don't try to create this proxy right now because it will slow
|
||||||
// down the program startup (especially if there is no DNS server
|
// down the program startup (especially if there is no DNS server
|
||||||
// available, in which case it may take up to 1 minute)
|
// available, in which case it may take up to 1 minute)
|
||||||
|
|
||||||
if ( getenv("HTTP_PROXY") )
|
if ( getenv("HTTP_PROXY") )
|
||||||
{
|
{
|
||||||
wxURL::ms_useDefaultProxy = TRUE;
|
wxURL::ms_useDefaultProxy = TRUE;
|
||||||
|
Reference in New Issue
Block a user