ruby-changes:19700
From: shyouhei <ko1@a...>
Date: Fri, 27 May 2011 11:49:07 +0900 (JST)
Subject: [ruby-changes:19700] shyouhei:r31744 (trunk): prevent an error when passing a frozen string to REXML::Text.new
shyouhei 2011-05-27 11:34:23 +0900 (Fri, 27 May 2011) New Revision: 31744 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31744 Log: prevent an error when passing a frozen string to REXML::Text.new dup the string passed in instead of cloning so that it's frozen state is ignored Signed-off-by: URABE, Shyouhei <shyouhei@r...> Modified files: trunk/lib/rexml/text.rb trunk/test/rexml/test_core.rb Index: lib/rexml/text.rb =================================================================== --- lib/rexml/text.rb (revision 31743) +++ lib/rexml/text.rb (revision 31744) @@ -105,7 +105,7 @@ @normalized = @unnormalized = nil if arg.kind_of? String - @string = arg.clone + @string = arg.dup @string.squeeze!(" \n\t") unless respect_whitespace elsif arg.kind_of? Text @string = arg.to_s Index: test/rexml/test_core.rb =================================================================== --- test/rexml/test_core.rb (revision 31743) +++ test/rexml/test_core.rb (revision 31744) @@ -349,6 +349,9 @@ assert_equal(string, text.to_s) text2 = Text.new(text) assert_equal(text, text2) + string = "Frozen".freeze + text3 = Text.new(string) + assert_equal(string, text3.to_s) #testing substitution string = "0 < ( 1 & 1 )" correct = "0 < ( 1 & 1 )" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/