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
{{ message }}
Repository navigation
Invalid UTF-8 Strings when compiling with MRB_UTF8_STRING compute length incorrectly #5269
When compiling mruby with UTF-8 Strings (e.g. setting CFLAGS="-DMRB_UTF8_STRING"), mruby incorrectly computes the length of strings with invalid UTF-8 byte sequences.
mruby
$ git rev-parse HEAD69482dbc8e590ed66f0944e9b48c4f9c2f83c873
$ git showcommit 69482dbc8e590ed66f0944e9b48c4f9c2f83c873 (HEAD -> master, origin/master, origin/HEAD)Merge: 6587269a f7ff4810Author: Yukihiro "Matz" Matsumoto <matz@ruby.or.jp>Date: Fri Jan 8 23:10:49 2021 +0900 Merge pull request #5265 from shuujii/reapply-116e128b-because-it-is-back-at-456878ba Reapply 116e128b because it is back at 456878ba
The length of broken UTF-8 strings is undefined, I think. You may get whatever length.
CRuby does validate if the string is UTF-8 compliant. mruby just assumes the string is valid UTF-8.
I will investigate if we can validate without hindering the performance.
Activity
Upgrade crates and tests to rand 0.8 ecosystem
matz commentedon Jan 9, 2021
The length of broken UTF-8 strings is undefined, I think. You may get whatever length.
CRuby does validate if the string is UTF-8 compliant. mruby just assumes the string is valid UTF-8.
I will investigate if we can validate without hindering the performance.
matz commentedon Jan 9, 2021
For this particular case (the first byte is in
80..C1) is checked now.