From c41a2882805dd95a3707d30f3969209cda639b10 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Fri, 28 Aug 2015 05:27:00 -0400 Subject: [PATCH] added null checks --- .../owasp/dependencycheck/reporting/EscapeTool.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/reporting/EscapeTool.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/reporting/EscapeTool.java index cf955bc27..f44d4b0d9 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/reporting/EscapeTool.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/reporting/EscapeTool.java @@ -24,8 +24,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * An extremely simple wrapper around various escape utils to perform URL and HTML encoding within the reports. This - * class was created to simplify the velocity configuration and avoid using the "built-in" escape tool. + * An extremely simple wrapper around various escape utils to perform URL and HTML encoding within the reports. This class was + * created to simplify the velocity configuration and avoid using the "built-in" escape tool. * * @author Jeremy Long */ @@ -43,6 +43,9 @@ public class EscapeTool { * @return the URL encoded text */ public String url(String text) { + if (text == null || text.isEmpty()) { + return text; + } try { return URLEncoder.encode(text, "UTF-8"); } catch (UnsupportedEncodingException ex) { @@ -59,6 +62,9 @@ public class EscapeTool { * @return the HTML encoded text */ public String html(String text) { + if (text == null || text.isEmpty()) { + return text; + } return StringEscapeUtils.escapeHtml(text); } @@ -69,6 +75,9 @@ public class EscapeTool { * @return the XML encoded text */ public String xml(String text) { + if (text == null || text.isEmpty()) { + return text; + } return StringEscapeUtils.escapeXml(text); } }