Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Treat invalid characters as single byte for length

  • Loading branch information...
commit 96534269834c77d98f36a37049b816b392b5eb6f 1 parent f38f73c
@dbussink dbussink authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 vm/builtin/string.cpp
View
9 vm/builtin/string.cpp
@@ -1706,9 +1706,12 @@ namespace rubinius {
for(i = 0; i < k && p < e; i++) {
int c = Encoding::precise_mbclen(p, e, enc);
- if(!ONIGENC_MBCLEN_CHARFOUND_P(c)) return nil<Fixnum>();
-
- p += ONIGENC_MBCLEN_CHARFOUND_LEN(c);
+ // If it's an invalid byte, just treat it as a single byte
+ if(!ONIGENC_MBCLEN_CHARFOUND_P(c)) {
+ ++p;
+ } else {
+ p += ONIGENC_MBCLEN_CHARFOUND_LEN(c);
+ }
}
if(i < k) {
Please sign in to comment.
Something went wrong with that request. Please try again.