You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you create a Matcher from a byte array containing invalid UTF-8, the match() method will spin forever due to invalid characters not being handled by ByteCodeMachine. For example, in the method opAnyCharStar():
while (s < range) {
...
int n = enc.length(bytes, s, end);
if (s + n > range) {opFail(); return;}
...
}
The enc.length() call returns -1 for malformed input, but this value isn't checked for, so the loop never exits. I haven't looked at this deeply enough to know the correct solution, but there are a ton of calls and none of them are checked.
The text was updated successfully, but these errors were encountered:
I wouldn't say this is by design, but Joni does assume you're passing it valid character sequences. Adding character verification everywhere it is needed would obviously add overhead to the character-walking logic in Joni, slowing down all matches.
However, in the case you show, adding a -1 check would not be a significant source of overhead...so it may be worth adding.
If you create a
Matcher
from a byte array containing invalid UTF-8, thematch()
method will spin forever due to invalid characters not being handled byByteCodeMachine
. For example, in the methodopAnyCharStar()
:The
enc.length()
call returns -1 for malformed input, but this value isn't checked for, so the loop never exits. I haven't looked at this deeply enough to know the correct solution, but there are a ton of calls and none of them are checked.The text was updated successfully, but these errors were encountered: