#include "wx/fontmap.h"
#include "wx/log.h"
#include "wx/settings.h"
+#include "wx/uri.h"
//-----------------------------------------------------------------------------
*/
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;
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;