safe.c: preserve encoding
* safe.c (rb_insecure_operation): preserve encoding of the called method name in error messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5af1a10d7c
commit
f77d402352
4
safe.c
4
safe.c
@ -110,8 +110,8 @@ rb_insecure_operation(void)
|
|||||||
{
|
{
|
||||||
ID caller_name = rb_frame_callee();
|
ID caller_name = rb_frame_callee();
|
||||||
if (caller_name) {
|
if (caller_name) {
|
||||||
rb_raise(rb_eSecurityError, "Insecure operation - %s",
|
rb_raise(rb_eSecurityError, "Insecure operation - %"PRIsVALUE,
|
||||||
rb_id2name(caller_name));
|
rb_id2str(caller_name));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_raise(rb_eSecurityError, "Insecure operation: -r");
|
rb_raise(rb_eSecurityError, "Insecure operation: -r");
|
||||||
|
@ -390,6 +390,12 @@ class TestFile < Test::Unit::TestCase
|
|||||||
(0..1).each do |level|
|
(0..1).each do |level|
|
||||||
assert_nothing_raised(SecurityError, bug5374) {in_safe[level]}
|
assert_nothing_raised(SecurityError, bug5374) {in_safe[level]}
|
||||||
end
|
end
|
||||||
|
def (s = Object.new).to_path; "".taint; end
|
||||||
|
m = "\u{691c 67fb}"
|
||||||
|
(c = Class.new(File)).singleton_class.class_eval {alias_method m, :stat}
|
||||||
|
assert_raise_with_message(SecurityError, /#{m}/) {
|
||||||
|
proc {$SAFE = 3; c.__send__(m, s)}.call
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if /(bcc|ms|cyg)win|mingw|emx/ =~ RUBY_PLATFORM
|
if /(bcc|ms|cyg)win|mingw|emx/ =~ RUBY_PLATFORM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user