javasript calls containing a string with newlines failed.
MODIFY
internal/scripting/javascript.go
internal/scripting/javascript.go
@@ -85,7 +85,7 @@ func (engine *JavaScriptEngine) readScriptsRecursively(dirname string) error {
func (engine *JavaScriptEngine) OnMessageSend(oldText string) (newText string) {
newText = oldText
for _, vm := range engine.vms {
- jsValue, jsError := vm.Run(fmt.Sprintf(`onMessageSend("%s")`, newText))
+ jsValue, jsError := vm.Run(fmt.Sprintf("onMessageSend(\"%s\")", escapeNewlines(newText)))
if jsError != nil {
//This script failed, go to next one
continue
@@ -95,3 +95,7 @@ func (engine *JavaScriptEngine) OnMessageSend(oldText string) (newText string) {
return
}
+
+func escapeNewlines(parameter string) string {
+ return strings.Replace(parameter, "\n", "\\n", -1)
+}

javasript calls containing a string with newlines failed.