From 61933f57d4fbeacc4ea1f9e08576e1946a914cc3 Mon Sep 17 00:00:00 2001 From: Diogo Almeida Date: Tue, 13 Mar 2018 16:31:50 +0000 Subject: [PATCH] Added ability to view logs with XML tags * Escape XML when colorizing * Escape XML in HTML when log entry starts with "" + logMessage + "
") + logDiv.append("
" + escapeXMLHtml(logMessage) + "
") } else { // log file doesn't exist yet. add it with this message console.log("adding new logFile " + logId); @@ -261,3 +261,16 @@ $( "#pause-button" ).click(function() { $( "#regex-button" ).click(function() { updateRegex() }); + +function escapeXMLHtml(unsafe) { + if(unsafe.startsWith("/g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + } else { + return unsafe; + } +} diff --git a/src/main/scala/com/jdrews/logstation/utils/LogStationColorizer.scala b/src/main/scala/com/jdrews/logstation/utils/LogStationColorizer.scala index 6d4debf..fbefb99 100644 --- a/src/main/scala/com/jdrews/logstation/utils/LogStationColorizer.scala +++ b/src/main/scala/com/jdrews/logstation/utils/LogStationColorizer.scala @@ -35,7 +35,7 @@ class LogStationColorizer extends Actor with ActorLogging { if (syntax._2.findFirstIn(lm.logMessage).isDefined) { // log.debug(s"got a match! ${syntax._1}") // wrap log message in new colors - msg = s"${lm.logMessage}" + msg = s"${xml.Utility.escape(lm.logMessage)}" loop.break } )