");
- sb.append("");
- sb.append(mr.getParent().getName()).append(".").append(mr.getName());
+ sb.append("");
+ sb.append(Util.escape(mr.getParent().getName())).append(".").append(Util.escape(mr.getName()));
sb.append("");
sb.append(" | ");
- sb.append(mr.getDescription());
+ sb.append(Util.escape(mr.getDescription()));
sb.append(" | ");
sb.append(FormatUtil.formatTime(mr.getDuration()));
sb.append(" | ");
@@ -154,7 +155,7 @@ private String getMethodExecutionTableContent(List mrList) {
sb.append(" | ");
- sb.append(mr.getStatus());
+ sb.append(Util.escape(mr.getStatus()));
sb.append(" |
");
}
return sb.toString();
diff --git a/src/main/java/hudson/plugins/testng/util/FormatUtil.java b/src/main/java/hudson/plugins/testng/util/FormatUtil.java
index 74932403..ed55226a 100644
--- a/src/main/java/hudson/plugins/testng/util/FormatUtil.java
+++ b/src/main/java/hudson/plugins/testng/util/FormatUtil.java
@@ -79,6 +79,25 @@ public static String escapeString(String str) {
return str;
}
+ public static String escapeJS(String str) {
+ if (str == null) {
+ return "";
+ }
+ StringBuilder buf = new StringBuilder(str.length() + 64);
+ for (int i = 0; i < str.length(); i++) {
+ char ch = str.charAt(i);
+ if (ch == '<') buf.append("<");
+ else if (ch == '>') buf.append(">");
+ else if (ch == '&') buf.append("&");
+ else if (ch == '\'') buf.append("'");
+ else if (ch == '\"') buf.append(""");
+ else if (ch == ':') buf.append(":");
+ else if (ch == '%') buf.append("%");
+ else buf.append(ch);
+ }
+ return buf.toString();
+ }
+
/**
* Formats the stack trace for easier readability
*
diff --git a/src/main/java/hudson/plugins/testng/util/TestResultHistoryUtil.java b/src/main/java/hudson/plugins/testng/util/TestResultHistoryUtil.java
index d6cc473a..5cb0052c 100644
--- a/src/main/java/hudson/plugins/testng/util/TestResultHistoryUtil.java
+++ b/src/main/java/hudson/plugins/testng/util/TestResultHistoryUtil.java
@@ -1,5 +1,6 @@
package hudson.plugins.testng.util;
+import hudson.Util;
import hudson.model.Run;
import hudson.plugins.testng.TestNGTestResultBuildAction;
import hudson.plugins.testng.results.ClassResult;
@@ -108,8 +109,8 @@ private static String printTestsUrls(List