5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 03:59:59 +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 ( import (
"context" "context"
"encoding/json" "encoding/json"
"html/template"
"log" "log"
"runtime" "runtime"
@ -310,7 +311,7 @@ func (f *Frontend) Notify(name string, data ...interface{}) {
f.logger.Error(err.Error()) f.logger.Error(err.Error())
return 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) { //func (f *Frontend) processRequest(req *edge.ICoreWebView2WebResourceRequest, args *edge.ICoreWebView2WebResourceRequestedEventArgs) {

View File

@ -11,6 +11,7 @@ import (
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
"text/template"
"github.com/leaanthony/slicer" "github.com/leaanthony/slicer"
@ -337,7 +338,7 @@ func (f *Frontend) Notify(name string, data ...interface{}) {
f.logger.Error(err.Error()) f.logger.Error(err.Error())
return 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) { func (f *Frontend) processRequest(req *edge.ICoreWebView2WebResourceRequest, args *edge.ICoreWebView2WebResourceRequestedEventArgs) {