mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (rb_reg_initialize): embedded string may override encoding
of the regular expression. * re.c (rb_reg_initialize): fix encoding of regular expression if embedded string has its own encoding specified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a648fc802b
commit
7bb3ea6afa
3 changed files with 24 additions and 11 deletions
|
@ -1,3 +1,11 @@
|
|||
Fri Dec 14 00:54:40 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* re.c (rb_reg_initialize): embedded string may override encoding
|
||||
of the regular expression.
|
||||
|
||||
* re.c (rb_reg_initialize): fix encoding of regular expression if
|
||||
embedded string has its own encoding specified.
|
||||
|
||||
Thu Dec 13 22:16:46 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* encoding.c (rb_enc_compatible): encoding should never fall back
|
||||
|
|
21
re.c
21
re.c
|
@ -1954,6 +1954,7 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
|
|||
struct RRegexp *re = RREGEXP(obj);
|
||||
VALUE unescaped;
|
||||
rb_encoding *fixed_enc = 0;
|
||||
rb_encoding *d_enc = rb_default_encoding();
|
||||
|
||||
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
|
||||
|
@ -1969,15 +1970,19 @@ rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
|
|||
if (unescaped == Qnil)
|
||||
return -1;
|
||||
|
||||
if (fixed_enc && fixed_enc != enc) {
|
||||
strcpy(err, "character encodings differ");
|
||||
return -1;
|
||||
if (fixed_enc) {
|
||||
if (fixed_enc != enc && enc != d_enc && fixed_enc != d_enc) {
|
||||
strcpy(err, "character encodings differ");
|
||||
return -1;
|
||||
}
|
||||
if (fixed_enc != d_enc) {
|
||||
options |= ARG_ENCODING_FIXED;
|
||||
enc = fixed_enc;
|
||||
}
|
||||
}
|
||||
else if (!(options & ARG_ENCODING_FIXED)) {
|
||||
enc = d_enc;
|
||||
}
|
||||
|
||||
if (fixed_enc)
|
||||
enc = fixed_enc;
|
||||
else if (!(options & ARG_ENCODING_FIXED))
|
||||
enc = rb_default_encoding();
|
||||
|
||||
rb_enc_associate((VALUE)re, enc);
|
||||
if ((options & ARG_ENCODING_FIXED) || fixed_enc) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2007-12-13"
|
||||
#define RUBY_RELEASE_DATE "2007-12-14"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20071213
|
||||
#define RUBY_RELEASE_CODE 20071214
|
||||
#define RUBY_PATCHLEVEL 0
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2007
|
||||
#define RUBY_RELEASE_MONTH 12
|
||||
#define RUBY_RELEASE_DAY 13
|
||||
#define RUBY_RELEASE_DAY 14
|
||||
|
||||
#ifdef RUBY_EXTERN
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
|
|
Loading…
Reference in a new issue