Skip to content

Commit c6da91d

Browse files
xeno6696kwwall
andauthored
PR to fix #517 and #588 (#591)
* Bump release to new release number, 2.2.2.0. * Fixed #517 and #588 with currently only one unit test failing. * Fixed my pom.xml for #588 and #517 * Fixed an encoding bug that was causing an early truncation involving invalid escape sequences. This was causing test input jeff\WILLIAMS to be converted to jeffWILLIAMS and then passing a validation test that it should have been failing. Special thanks to Jeremiah Stacey for the root cause analysis and repair. For #517 and #588. Co-authored-by: kwwall <[email protected]> Co-authored-by: xeno6696 <xeno6696[at]gmail.com>
1 parent e17ae39 commit c6da91d

File tree

6 files changed

+102
-46
lines changed

6 files changed

+102
-46
lines changed

src/main/java/org/owasp/esapi/codecs/JavaScriptCodec.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ public Character decodeCharacter( PushbackSequence<Character> input ) {
211211
}
212212

213213
// ignore the backslash and return the character
214-
return second;
214+
input.reset();
215+
return null;
215216
}
216217

217218
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,16 @@ public String getValid( String context, String input ) throws ValidationExceptio
274274
if (canonicalizeInput) {
275275
data = encoder.canonicalize(input);
276276
} else {
277-
String message = String.format("Input validaiton excludes canonicalization. Context: %s Input: %s", context, input);
277+
String message = String.format("Input validation excludes canonicalization. Context: %s Input: %s", context, input);
278278
LOGGER.warning(Logger.SECURITY_AUDIT, message);
279279
data = input;
280280
}
281281

282282
// check whitelist patterns
283-
checkWhitelist(context, input);
283+
checkWhitelist(context, data, input);
284284

285285
// check blacklist patterns
286-
checkBlacklist(context, input);
286+
checkBlacklist(context, data, input);
287287

288288
// validation passed
289289
return data;

src/test/java/org/owasp/esapi/reference/EncoderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void testCanonicalize() throws EncodingException {
232232
assertEquals( "\'", instance.canonicalize("\\'"));
233233
assertEquals( "\"", instance.canonicalize("\\\""));
234234
assertEquals( "\\", instance.canonicalize("\\\\"));
235-
assertEquals( "<", instance.canonicalize("\\<"));
235+
assertEquals( "\\<", instance.canonicalize("\\<"));
236236

237237
assertEquals( "<", instance.canonicalize("\\u003c"));
238238
assertEquals( "<", instance.canonicalize("\\U003c"));

0 commit comments

Comments
 (0)