Browse Source

Update

tags/CommEngine-0.0.1
ymlam 6 years ago
parent
commit
e56690259a
2 changed files with 14 additions and 2 deletions
  1. +3
    -2
      src/altk/comm/engine/Broadcast.java
  2. +11
    -0
      src/altk/comm/engine/Util.java

+ 3
- 2
src/altk/comm/engine/Broadcast.java View File

@@ -807,12 +807,13 @@ public abstract class Broadcast
{ {
if (haltReason != null) if (haltReason != null)
{ {
statusBf.append("<reason>" + haltReason
// Escaping '&' and '<' in haltReason before enclosing it in <reason> tag
statusBf.append("<reason>" + Util.xmlEscape(haltReason)
+ "</reason>\r\n"); + "</reason>\r\n");
} }
if (stateErrorText != null) if (stateErrorText != null)
{ {
statusBf.append("<error_text>" + stateErrorText
statusBf.append("<error_text>" + Util.xmlEscape(stateErrorText)
+ "</error_text>"); + "</error_text>");
} }
} }


+ 11
- 0
src/altk/comm/engine/Util.java View File

@@ -4,6 +4,17 @@ import java.util.Properties;


public class Util public class Util
{ {
/**
* Escape xml sensitive characters '<' and '&' in argument str with appropriate "&xxx;".
* @param str
* @return str with '<' and '&' escaped so it is appropriate to be embeeded as
* text in an xml/html tag.
*/
static public String xmlEscape(String str)
{
return str.replace("&", "&amp;").replace("<", "&lt;");
}
static public String getStringParameter(String name, Properties config) static public String getStringParameter(String name, Properties config)
{ {
return getStringParameter(name, config, null); return getStringParameter(name, config, null);


Loading…
Cancel
Save