Skip to content

Commit 964abcc

Browse files
committedMar 2, 2024·
Escape bindings, even though we generate them internally.
1 parent 5d22da4 commit 964abcc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎v2/pkg/assetserver/assetserver.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"golang.org/x/net/html"
11+
"html/template"
1112

1213
"github.com/wailsapp/wails/v2/pkg/options"
1314
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
@@ -67,9 +68,11 @@ func NewAssetServer(bindingsJSON string, options assetserver.Options, servingFro
6768
}
6869

6970
func NewAssetServerWithHandler(handler http.Handler, bindingsJSON string, servingFromDisk bool, logger Logger, runtime RuntimeAssets) (*AssetServer, error) {
71+
7072
var buffer bytes.Buffer
7173
if bindingsJSON != "" {
72-
buffer.WriteString(`window.wailsbindings='` + bindingsJSON + `';` + "\n")
74+
escapedBindingsJSON := template.JSEscapeString(bindingsJSON)
75+
buffer.WriteString(`window.wailsbindings='` + escapedBindingsJSON + `';` + "\n")
7376
}
7477
buffer.Write(runtime.RuntimeDesktopJS())
7578

0 commit comments

Comments
 (0)
Please sign in to comment.