File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
src/main/java/org/owasp/esapi/codecs Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -250,12 +250,21 @@ private Character getNamedEntity( PushbackString input ) {
250
250
// kludge around PushbackString....
251
251
len = Math .min (input .remainder ().length (), entityToCharacterTrie .getMaxKeyLength ());
252
252
for (int i =0 ;i <len ;i ++)
253
- possible .append (Character . toLowerCase ( input .next () ));
253
+ possible .append (input .next ());
254
254
255
255
// look up the longest match
256
256
entry = entityToCharacterTrie .getLongestMatch (possible );
257
- if (entry == null )
258
- return null ; // no match, caller will reset input
257
+ if (entry == null ) {
258
+ // We are lowercasing & comparing the result because of this all the upper case named entities are getting converted lowercase named entities.
259
+ // check is there any exact match https://github.com/ESAPI/esapi-java-legacy/issues/302
260
+ String possibleString = possible .toString ();
261
+ String possibleStringLowerCase = possibleString .toLowerCase ();
262
+ if (!possibleString .equals (possibleStringLowerCase )) {
263
+ Map .Entry <CharSequence ,Character > exactEntry = entityToCharacterTrie .getLongestMatch (possibleStringLowerCase );
264
+ if (exactEntry != null ) entry = exactEntry ;
265
+ }
266
+ if (entry == null ) return null ; // no match, caller will reset input
267
+ }
259
268
260
269
// fixup input
261
270
input .reset ();
You can’t perform that action at this time.
0 commit comments