Mercurial > dwindows
changeset 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 | a3fbe505307a |
children | 026f033ac1c1 |
files | win/edge.cpp |
diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/win/edge.cpp Sat Nov 30 23:07:09 2019 +0000 +++ b/win/edge.cpp Mon Dec 02 03:49:09 2019 +0000 @@ -293,9 +293,23 @@ Callback<IWebView2ExecuteScriptCompletedHandler>( [thishwnd, scriptdata](HRESULT error, PCWSTR result) -> HRESULT { + char *scriptresult; + + /* Result is unquoted "null" when we should return NULL */ if (result && _wcsicmp(result, L"null") == 0) - result = NULL; - void *params[2] = { (void *)(result ? WideToUTF8((LPWSTR)result) : NULL), DW_INT_TO_POINTER((error == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)) }; + scriptresult = NULL; + else + scriptresult = result ? WideToUTF8((LPWSTR)result) : NULL; + + /* String results are enclosed in quotations, remove the quotes */ + if(scriptresult && *scriptresult == '\"') + { + char *end = strrchr(scriptresult, '\"'); + if(end) + *end = '\0'; + scriptresult++; + } + void *params[2] = { (void *)scriptresult, DW_INT_TO_POINTER((error == S_OK ? DW_ERROR_NONE : DW_ERROR_UNKNOWN)) }; _wndproc(thishwnd, WM_USER + 100, (WPARAM)params, (LPARAM)scriptdata); return S_OK; }).Get());