Skip to content

Commit 135950c

Browse files
author
mzilu
committed
Use existing toString method rather than a StringBuilder
Lists will compile its contents when toString() is called against it, making the StringBuilder and iteration unnecessary. This change was made as a result of the review from GitHub PR #510
1 parent d869303 commit 135950c

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/main/java/org/owasp/esapi/reference/validation/HTMLValidationRule.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,7 @@ private String invokeAntiSamy( String context, String input ) throws ValidationE
114114

115115
List<String> errors = test.getErrorMessages();
116116
if ( !errors.isEmpty() ) {
117-
StringBuilder sb = new StringBuilder();
118-
for ( int i = 0; i < errors.size(); i++ ) {
119-
sb.append(errors.get(i));
120-
if ( i != errors.size() - 1 ) {
121-
sb.append(",");
122-
}
123-
}
124-
throw new ValidationException( context + ": Invalid HTML input", "Invalid HTML input does not follow rules in antisamy-esapi.xml: context=" + context + " errors=" + sb.toString());
117+
throw new ValidationException( context + ": Invalid HTML input", "Invalid HTML input does not follow rules in antisamy-esapi.xml: context=" + context + " errors=" + errors.toString());
125118
}
126119

127120
return test.getCleanHTML().trim();

0 commit comments

Comments
 (0)