Skip to content

Commit

Permalink
Fix #5999 ArrayIndexOutOfBounds for unicode in HttpURI segment (#6000)
Browse files Browse the repository at this point in the history
Fixed ArrayTrie to not throw if passed a unicode character.
  • Loading branch information
gregw authored Feb 23, 2021
1 parent 16241d7 commit 8bd4a9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ public static Stream<Arguments> decodePathTests()
{"%2f/info", "//info", true},
{"%2F/info", "//info", true},

// Non ascii characters
{"http://localhost:9000/x\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32", "/x\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32", false},
{"http://localhost:9000/\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32", "/\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32", false},
}).map(Arguments::of);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ public V get(String s, int offset, int len)
for (int i = 0; i < len; i++)
{
char c = s.charAt(offset + i);
if (c > 0x7f)
return null;
int index = __lookup[c & 0x7f];
if (index >= 0)
{
Expand All @@ -217,7 +219,7 @@ public V get(String s, int offset, int len)
char[] big = _bigIndex == null ? null : _bigIndex[t];
if (big == null)
return null;
t = big[c];
t = big[c & 0x7f];
if (t == 0)
return null;
}
Expand Down

0 comments on commit 8bd4a9f

Please sign in to comment.