1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

error.c: check argument of Warning.warn

* error.c (rb_warning_s_warn): the argument must be an
  ASCII-compatible string.  [ruby-core:77430] [Bug #12793]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-09-27 15:21:01 +00:00
parent 3d2e45d319
commit d28bac1cae
3 changed files with 19 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Wed Sep 28 00:21:00 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (rb_warning_s_warn): the argument must be an
ASCII-compatible string. [ruby-core:77430] [Bug #12793]
Tue Sep 27 23:22:31 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (symbol, dsym, parser_set_number_literal): set state to

View file

@ -152,6 +152,8 @@ ruby_only_for_internal_use(const char *func)
static VALUE
rb_warning_s_warn(VALUE mod, VALUE str)
{
Check_Type(str, T_STRING);
rb_must_asciicompat(str);
rb_write_error_str(str);
return Qnil;
}

View file

@ -940,4 +940,16 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
remove_method :warn2
end
end
def test_warning_warn_invalid_argument
assert_raise(TypeError) do
::Warning.warn nil
end
assert_raise(TypeError) do
::Warning.warn 1
end
assert_raise(Encoding::CompatibilityError) do
::Warning.warn "\x00a\x00b\x00c".force_encoding("utf-16be")
end
end
end