Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-17878 Escape HTML in test results comments
  • Loading branch information
kinow committed Jul 23, 2013
1 parent 295d37a commit 279e120
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/tap4j/plugin/TapParser.java
Expand Up @@ -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() {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/tap4j/plugin/TapResult.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/org/tap4j/plugin/tags/line.jelly
Expand Up @@ -31,7 +31,7 @@
<tr>
<td></td>
<td colspan='3'>
# ${tapLine.text}<br/>
# ${it.escapeHTML(tapLine.text)}<br/>
</td>
</tr>
</j:when>
Expand Down

0 comments on commit 279e120

Please sign in to comment.