Skip to content

Commit 8bd4a9f

Browse files
authored
Fix #5999 ArrayIndexOutOfBounds for unicode in HttpURI segment (#6000)
Fixed ArrayTrie to not throw if passed a unicode character.
1 parent 16241d7 commit 8bd4a9f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

jetty-http/src/test/java/org/eclipse/jetty/http/HttpURITest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ public static Stream<Arguments> decodePathTests()
337337
{"%2f/info", "//info", true},
338338
{"%2F/info", "//info", true},
339339

340+
// Non ascii characters
341+
{"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},
342+
{"http://localhost:9000/\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32", "/\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32\uD83C\uDF32", false},
340343
}).map(Arguments::of);
341344
}
342345

jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTrie.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ public V get(String s, int offset, int len)
204204
for (int i = 0; i < len; i++)
205205
{
206206
char c = s.charAt(offset + i);
207+
if (c > 0x7f)
208+
return null;
207209
int index = __lookup[c & 0x7f];
208210
if (index >= 0)
209211
{
@@ -217,7 +219,7 @@ public V get(String s, int offset, int len)
217219
char[] big = _bigIndex == null ? null : _bigIndex[t];
218220
if (big == null)
219221
return null;
220-
t = big[c];
222+
t = big[c & 0x7f];
221223
if (t == 0)
222224
return null;
223225
}

0 commit comments

Comments
 (0)