Skip to content

Commit b14d148

Browse files
author
planetlevel
committed
Bugfix for looking up characters > 255
1 parent 1c8f112 commit b14d148

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public Character decodeCharacter( PushbackString input ) {
114114
* Lookup the hex value of any character that is not alphanumeric, return null if alphanumeric.
115115
*/
116116
public static String getHex( char c ) {
117-
return hex[(int)c];
117+
if ( c > 0xFF ) return null;
118+
return hex[c];
118119
}
119120

120121
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ public void testEncodeForHTML() throws Exception {
353353
assertEquals(",.-_ ", instance.encodeForHTML(",.-_ "));
354354
assertEquals("dir&", instance.encodeForHTML("dir&"));
355355
assertEquals("one&two", instance.encodeForHTML("one&two"));
356+
assertEquals("" + (char)12345 + (char)65533 + (char)1244, "" + (char)12345 + (char)65533 + (char)1244 );
356357
}
357358

358359
/**

0 commit comments

Comments
 (0)