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