From: Kazuhiko Shiozaki Date: 2009-08-03T00:30:58+09:00 Subject: [ruby-dev:38982] [Bug #1864] Ruby-1.8.7 $SAFE=4のarray/hashのrecursive比較でSecurityError Bug #1864: Ruby-1.8.7 $SAFE=4のarray/hashのrecursive比較でSecurityError http://redmine.ruby-lang.org/issues/show/1864 起票者: Kazuhiko Shiozaki ステータス: Open, 優先度: Normal ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux] tDiaryのセキュアモード($SAFE=4)で、 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=16081 Author: knu Date: Sat Apr 19 11:11:25 2008 UTC (15 months, 1 week ago) Log Message: * array.c (rb_ary_equal, rb_ary_eql, rb_ary_hash, rb_ary_cmp): Make Array#eql?, #hash, #== and #<=> use rb_exec_recursive() and handle recursive data properly. * hash.c (hash_equal, rb_hash_hash): Make Hash#eql?, #hash and #== use rb_exec_recursive() and handle recursive data properly. 以降、不可解なSecurityError例外が起きます。 再現する短いRubyコードを書けていない(というか、似たようなコードを書いたつもりでも、うまく動いてしまう)のですが、 @referers = { 'foo' => [2, 'foo'], 'bar' => [1, 'bar'] } に対して、 @referers.values.sortで Insecure: can't modify hash (SecurityError) /home/tdiary/tdiary/core/tdiary.rb:285:in `<=>' となったり、 @scanner_map = {[nil, false]=>ERB::Compiler::SimpleScanner2, [nil, true]=>ERB::Compiler::PercentScanner, ["-", false]=>ERB::Compiler::ExplicitScanner} に対して、 @scanner_map.fetch([nil, false], ERB::Compiler::TrimScanner)で Insecure: can't modify hash /usr/lib/ruby/1.8/erb.rb:274:in `hash' /usr/lib/ruby/1.8/erb.rb:274:in `fetch' となったりします。 いずれのケースも、modifyしないはずなのに、"Insecure: can't modify hash"という 例外メッセージはおかしいのではないでしょうか。 どうぞよろしくお願いします。 かずひこ ---------------------------------------- http://redmine.ruby-lang.org