Fix XSS in HTML renderer

This commit is contained in:
Sergey
2017-04-28 10:38:48 -07:00
parent 9fae304b6f
commit 985299b490

View File

@ -9,6 +9,8 @@ import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.StringEscapeUtils;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleViolation;
@ -122,7 +124,7 @@ public class HTMLRenderer extends AbstractIncrementingRenderer {
buf.append("> " + PMD.EOL);
buf.append("<td align=\"center\">" + violationCount + "</td>" + PMD.EOL);
buf.append("<td width=\"*%\">"
+ maybeWrap(rv.getFilename(),
+ maybeWrap(StringEscapeUtils.escapeHtml(rv.getFilename()),
linePrefix == null ? "" : linePrefix + Integer.toString(rv.getBeginLine()))
+ "</td>" + PMD.EOL);
buf.append("<td align=\"center\" width=\"5%\">" + Integer.toString(rv.getBeginLine()) + "</td>" + PMD.EOL);