From 43f84a9c18ece7ada66cd11bf028ff547ec98ce1 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 28 Jul 2020 21:01:12 +0200 Subject: [PATCH] Use security URL from wxWebViewHandler in wxWebViewIE Don't use hard-coded 'http://localhost', but use the URL specified in the wxWebViewHandler. By default, the security URL is empty and no modifications are made when parsing a URL. This fixes using JavaScript in pages loaded with a custom protocol, e.g. from wxWebViewFSHandler or wxWebViewArchiveHandler. Closes #17893 --- src/msw/webview_ie.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/msw/webview_ie.cpp b/src/msw/webview_ie.cpp index 4ca3abdc26..cc85f27c5b 100644 --- a/src/msw/webview_ie.cpp +++ b/src/msw/webview_ie.cpp @@ -1762,25 +1762,23 @@ HRESULT STDMETHODCALLTYPE VirtualProtocol::ParseUrl( DWORD dwReserved) { wxUnusedVar(pwzUrl); - wxUnusedVar(ParseAction); wxUnusedVar(dwParseFlags); - wxUnusedVar(pwzResult); - wxUnusedVar(cchResult); - wxUnusedVar(pcchResult); wxUnusedVar(dwReserved); - switch (ParseAction) + const size_t secLen = m_handler->GetSecurityURL().length(); + if ( secLen > 0 ) { - case wxPARSE_SECURITY_URL: - case wxPARSE_SECURITY_DOMAIN: + switch ( ParseAction ) { - const wchar_t Result[] = L"http://localhost"; - size_t Len = wcslen(Result); - if(cchResult <= Len) - return S_FALSE; - wcscpy(pwzResult, Result); - *pcchResult = Len; - return S_OK; + case wxPARSE_SECURITY_URL: + case wxPARSE_SECURITY_DOMAIN: + { + if ( cchResult <= secLen ) + return S_FALSE; + wcscpy(pwzResult, m_handler->GetSecurityURL().wc_str()); + *pcchResult = secLen; + return S_OK; + } } }