comparison win/edge.cpp @ 2052:cfa0a9554118

Win: Edge (Chromium) HTML_RESULT returns a quoted result which needs to be removed. This removes the concern about an expected "null" return, since that is not quoted.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 02 Dec 2019 03:49:09 +0000
parents cb195d76de8e
children 21bc72ff40cb
comparison
equal deleted inserted replaced
2051:a3fbe505307a 2052:cfa0a9554118
291 if (WebView) 291 if (WebView)
292 WebView->ExecuteScript(UTF8toWide(script), 292 WebView->ExecuteScript(UTF8toWide(script),
293 Callback<IWebView2ExecuteScriptCompletedHandler>( 293 Callback<IWebView2ExecuteScriptCompletedHandler>(
294 [thishwnd, scriptdata](HRESULT error, PCWSTR result) -> HRESULT 294 [thishwnd, scriptdata](HRESULT error, PCWSTR result) -> HRESULT
295 { 295 {
296 char *scriptresult;
297
298 /* Result is unquoted "null" when we should return NULL */
296 if (result && _wcsicmp(result, L"null") == 0) 299 if (result && _wcsicmp(result, L"null") == 0)
297 result = NULL; 300 scriptresult = NULL;
298 void *params[2] = { (void *)(result ? WideToUTF8((LPWSTR)result) : NULL), DW_INT_TO_POINTER((error == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)) }; 301 else
302 scriptresult = result ? WideToUTF8((LPWSTR)result) : NULL;
303
304 /* String results are enclosed in quotations, remove the quotes */
305 if(scriptresult && *scriptresult == '\"')
306 {
307 char *end = strrchr(scriptresult, '\"');
308 if(end)
309 *end = '\0';
310 scriptresult++;
311 }
312 void *params[2] = { (void *)scriptresult, DW_INT_TO_POINTER((error == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)) };
299 _wndproc(thishwnd, WM_USER + 100, (WPARAM)params, (LPARAM)scriptdata); 313 _wndproc(thishwnd, WM_USER + 100, (WPARAM)params, (LPARAM)scriptdata);
300 return S_OK; 314 return S_OK;
301 }).Get()); 315 }).Get());
302 return DW_ERROR_NONE; 316 return DW_ERROR_NONE;
303 } 317 }