diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js
index 0972a6637..56c0c5859 100644
--- a/openlp/plugins/remotes/html/openlp.js
+++ b/openlp/plugins/remotes/html/openlp.js
@@ -208,7 +208,9 @@ window.OpenLP = {
},
showAlert: function (event) {
event.preventDefault();
- var text = "{\"request\": {\"text\": " + $("#alert-text").val() + "}}";
+ var text = "{\"request\": {\"text\": \"" +
+ $("#alert-text").val().replace(/\\/g, "\\\\").replace(/"/g, "\\\"") +
+ "\"}}";
$.getJSON(
"/api/alert",
{"data": text},
@@ -219,7 +221,9 @@ window.OpenLP = {
},
search: function (event) {
event.preventDefault();
- var text = "{\"request\": {\"text\": \"" + $("#search-text").val() + "\"}}";
+ var text = "{\"request\": {\"text\": \"" +
+ $("#search-text").val().replace(/\\/g, "\\\\").replace(/"/g, "\\\"") +
+ "\"}}";
$.getJSON(
"/api/" + $("#search-plugin").val() + "/search",
{"data": text},