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
In this example, the byte array related to str1 is: byte_array => [65, 0, 65, 0, 0, 0, 66, 0, 66, 0, 0, 0, 67, 0, 67, 0]
and the delimiter character (str2) is: delim => [0, 0]
The first time it is called, indexOf() will match byte_array[3] and byte_array[4] instead of matching byte_array[4] and byte_array[5] and returning 4.
The text was updated successfully, but these errors were encountered:
Environment
Expected Behavior
Splitting an encoded string with a null byte delimiter should returns the expected array of strings.
Example script (test.rb):
Expected result (CRuby):
Actual Behavior
JRuby does not properly split the string:
The issue is in
indexOf()
method from RubyString.java (https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyString.java#L4258). This method looks for the index of a specified substring (or character) in a byte array without considering the real size of the encoded characters.In this example, the byte array related to
str1
is:byte_array => [65, 0, 65, 0, 0, 0, 66, 0, 66, 0, 0, 0, 67, 0, 67, 0]
and the delimiter character (
str2
) is:delim => [0, 0]
The first time it is called,
indexOf()
will match byte_array[3] and byte_array[4] instead of matching byte_array[4] and byte_array[5] and returning 4.The text was updated successfully, but these errors were encountered: