5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 02:50:36 +08:00

Merge pull request #849 from marktohark/filter-execjs-json

add template.JSEscapeString to ensure ExecJs normal execution
This commit is contained in:
Lea Anthony 2021-10-06 20:13:19 +11:00 committed by GitHub
commit ef362a746a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -5,6 +5,7 @@ package darwin
import (
"context"
"encoding/json"
"html/template"
"log"
"runtime"
@ -310,7 +311,7 @@ func (f *Frontend) Notify(name string, data ...interface{}) {
f.logger.Error(err.Error())
return
}
f.ExecJS(`window.wails.EventsNotify('` + string(payload) + `');`)
f.ExecJS(`window.wails.EventsNotify('` + template.JSEscapeString(string(payload)) + `');`)
}
//func (f *Frontend) processRequest(req *edge.ICoreWebView2WebResourceRequest, args *edge.ICoreWebView2WebResourceRequestedEventArgs) {

View File

@ -11,6 +11,7 @@ import (
"runtime"
"strconv"
"strings"
"text/template"
"github.com/leaanthony/slicer"
@ -337,7 +338,7 @@ func (f *Frontend) Notify(name string, data ...interface{}) {
f.logger.Error(err.Error())
return
}
f.ExecJS(`window.wails.EventsNotify('` + string(payload) + `');`)
f.ExecJS(`window.wails.EventsNotify('` + template.JSEscapeString(string(payload)) + `');`)
}
func (f *Frontend) processRequest(req *edge.ICoreWebView2WebResourceRequest, args *edge.ICoreWebView2WebResourceRequestedEventArgs) {