From 8bd4ad02fd797e53f3ca7bafba0f076b039f8f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 13 Mar 2012 02:58:30 +0200 Subject: [PATCH] Fixes traceback when sending # or ; from web remote search or alert field. Fixes: https://launchpad.net/bugs/908226 --- openlp/plugins/remotes/html/openlp.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 56c0c5859..8377912f8 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -208,9 +208,8 @@ window.OpenLP = { }, showAlert: function (event) { event.preventDefault(); - var text = "{\"request\": {\"text\": \"" + - $("#alert-text").val().replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + - "\"}}"; + var alert = OpenLP.escapeString($("#alert-text").val()) + var text = "{\"request\": {\"text\": \"" + alert + "\"}}"; $.getJSON( "/api/alert", {"data": text}, @@ -221,9 +220,8 @@ window.OpenLP = { }, search: function (event) { event.preventDefault(); - var text = "{\"request\": {\"text\": \"" + - $("#search-text").val().replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + - "\"}}"; + var query = OpenLP.escapeString($("#search-text").val()) + var text = "{\"request\": {\"text\": \"" + query + "\"}}"; $.getJSON( "/api/" + $("#search-plugin").val() + "/search", {"data": text}, @@ -280,6 +278,10 @@ window.OpenLP = { ); $("#options").dialog("close"); $.mobile.changePage("#service-manager"); + }, + escapeString: function (string) { + string = string.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + return string.replace(/#/g, "\\u0023").replace(/;/g, "\\u003B") } } // Service Manager