diff --git a/activemq-web-demo/src/main/webapp/websocket/chat.js b/activemq-web-demo/src/main/webapp/websocket/chat.js index fe08d1bb06..e89bf098df 100644 --- a/activemq-web-demo/src/main/webapp/websocket/chat.js +++ b/activemq-web-demo/src/main/webapp/websocket/chat.js @@ -29,7 +29,7 @@ $(document).ready(function(){ // this allows to display debug logs directly on the web page client.debug = function(str) { - $("#debug").append(str + "\n"); + $("#debug").append(document.createTextNode(str + "\n")); }; // the client is notified when it is connected to the server. var onconnect = function(frame) { @@ -39,7 +39,7 @@ $(document).ready(function(){ $('#send_form_input').removeAttr('disabled'); client.subscribe(destination, function(message) { - $("#messages").append("

" + message.body + "

\n"); + $("#messages").append(document.createTextNode("

" + message.body + "

\n")); }); }; client.connect(login, passcode, onconnect); diff --git a/activemq-web/src/main/java/org/apache/activemq/web/PortfolioPublishServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/PortfolioPublishServlet.java index 046ea0dff8..351ff91d9b 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/PortfolioPublishServlet.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/PortfolioPublishServlet.java @@ -70,7 +70,8 @@ public class PortfolioPublishServlet extends MessageServletSupport { } out.print(refreshRate); out.println("'/>"); - out.println("Published " + count + " of " + total + " price messages. Refresh = " + refreshRate + "s"); + out.println("Published " + escape(Integer.toString(count)) + " of " + escape(Integer.toString(total)) + + " price messages. Refresh = " + escape(refreshRate) + "s"); out.println(""); } catch (JMSException e) { @@ -129,4 +130,8 @@ public class PortfolioPublishServlet extends MessageServletSupport { } return 1; } + + protected String escape(String text) throws IOException { + return java.net.URLEncoder.encode(text, "UTF-8"); + } }