Skip to content

Commit 258be73

Browse files
committed
Fix #2528. RegexpError: invalid multibyte character
1 parent 1c0f056 commit 258be73

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

core/src/main/java/org/jruby/RubyString.java

+4-12
Original file line numberDiff line numberDiff line change
@@ -3093,18 +3093,10 @@ private IRubyObject gsubCommon19(ThreadContext context, Block block, RubyString
30933093
private IRubyObject gsubCommon19(ThreadContext context, Block block, RubyString repl,
30943094
RubyHash hash, IRubyObject arg0, final boolean bang, int tuFlags, boolean useBackref) {
30953095
Ruby runtime = context.runtime;
3096-
3097-
final Regex pattern, prepared;
3098-
final RubyRegexp regexp;
3099-
if (arg0 instanceof RubyRegexp) {
3100-
regexp = (RubyRegexp)arg0;
3101-
pattern = regexp.getPattern();
3102-
prepared = regexp.preparePattern(this);
3103-
} else {
3104-
regexp = null;
3105-
pattern = getStringPattern19(runtime, arg0);
3106-
prepared = RubyRegexp.preparePattern(runtime, pattern, this);
3107-
}
3096+
RubyRegexp regexp = arg0 instanceof RubyRegexp ? (RubyRegexp) arg0 :
3097+
RubyRegexp.newRegexp(runtime, RubyRegexp.quote19(getStringForPattern(arg0).getByteList(), false), new RegexpOptions());
3098+
Regex pattern = regexp.getPattern();
3099+
Regex prepared = regexp.preparePattern(this);
31083100

31093101
final int begin = value.getBegin();
31103102
int slen = value.getRealSize();

0 commit comments

Comments
 (0)