X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d1da887276915d7b83dc7beff43bbe0deea35939..9e7efd538e888419f278d621f39c8776d28f3b18:/src/html/winpars.cpp?ds=sidebyside diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp index 344ade10a0..0dbab9d1f9 100644 --- a/src/html/winpars.cpp +++ b/src/html/winpars.cpp @@ -32,6 +32,7 @@ #include "wx/fontmap.h" #include "wx/log.h" #include "wx/settings.h" +#include "wx/uri.h" //----------------------------------------------------------------------------- @@ -192,7 +193,7 @@ void wxHtmlWinParser::InitParser(const wxString& source) */ m_UseLink = false; - m_Link = wxHtmlLinkInfo( wxT(""), wxT("") ); + m_Link = wxHtmlLinkInfo( wxEmptyString ); m_LinkColor.Set(0, 0, 0xFF); m_ActualColor.Set(0, 0, 0); m_Align = wxHTML_ALIGN_LEFT; @@ -248,16 +249,45 @@ wxObject* wxHtmlWinParser::GetProduct() wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type, const wxString& url) const { - // FIXME - normalize the URL to full path before passing to - // OnOpeningURL!! if ( m_Window ) { wxString myurl(url); wxHtmlOpeningStatus status; for (;;) { + wxString myfullurl(myurl); + + // consider url as absolute path first + wxURI current(myurl); + myfullurl = current.BuildUnescapedURI(); + + // if not absolute then ... + if( current.IsReference() ) + { + wxString basepath = GetFS()->GetPath(); + wxURI base(basepath); + + // ... try to apply base path if valid ... + if( !base.IsReference() ) + { + wxURI path(myfullurl); + path.Resolve( base ); + myfullurl = path.BuildUnescapedURI(); + } + else + { + // ... or force such addition if not included already + if( !current.GetPath().Contains(base.GetPath()) ) + { + basepath += myurl; + wxURI connected( basepath ); + myfullurl = connected.BuildUnescapedURI(); + } + } + } + wxString redirect; - status = m_Window->OnOpeningURL(type, myurl, &redirect); + status = m_Window->OnOpeningURL(type, myfullurl, &redirect); if ( status != wxHTML_REDIRECT ) break;