Skip to content
Permalink
Browse files

JENKINS-17878 Escape HTML in test results comments

  • Loading branch information...
kinow committed Jul 23, 2013
1 parent 295d37a commit 279e1204335f2092f6beeababf174068223b6047
@@ -80,7 +80,7 @@ public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, Boolean tod
this.todoIsFailure = todoIsFailure;
this.logger = logger;
this.parserErrors = false;
this.includeCommentDiagnostics = false;
this.includeCommentDiagnostics = includeCommentDiagnostics;
}

public boolean hasParserErrors() {
@@ -38,6 +38,7 @@
import javax.servlet.ServletOutputStream;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;
@@ -296,6 +297,10 @@ public boolean isBailOut(Object tapResult) {
public boolean isComment(Object tapResult) {
return (tapResult != null && tapResult instanceof Comment);
}

public String escapeHTML(String html) {
return StringUtils.replaceEach(html, new String[]{"&", "\"", "<", ">"}, new String[]{"&amp;", "&quot;", "&lt;", "&gt;"});
}

/**
* @return the name
@@ -31,7 +31,7 @@
<tr>
<td></td>
<td colspan='3'>
# ${tapLine.text}<br/>
# ${it.escapeHTML(tapLine.text)}<br/>
</td>
</tr>
</j:when>

0 comments on commit 279e120

Please sign in to comment.
You can’t perform that action at this time.