From 3cefaf62788ca8eda1747c0db7dfcd350b6978f2 Mon Sep 17 00:00:00 2001 From: yugui Date: Tue, 31 May 2011 00:12:54 +0000 Subject: merges r31744 and r31745 from trunk into ruby_1_9_2. -- 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 -- ChangeLog for it git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ lib/rexml/text.rb | 2 +- test/rexml/test_core.rb | 3 +++ version.h | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad1e979d6a..610d34ce4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri May 27 11:31:51 2011 misfo + + * lib/rexml/text.rb (REXML::Text#initialize): 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 + Sun May 22 07:10:25 2011 Martin Bosslet * test/openssl/test_pkey_dsa.rb: Add tests for sign/verify. diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb index 05d5341abb..6623c0c03b 100644 --- a/lib/rexml/text.rb +++ b/lib/rexml/text.rb @@ -105,7 +105,7 @@ module REXML @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 diff --git a/test/rexml/test_core.rb b/test/rexml/test_core.rb index 48a31aee0e..204be0fdff 100644 --- a/test/rexml/test_core.rb +++ b/test/rexml/test_core.rb @@ -371,6 +371,9 @@ class Tester < Test::Unit::TestCase 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 )" diff --git a/version.h b/version.h index f124c040dd..b67bfb8dd8 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 257 +#define RUBY_PATCHLEVEL 258 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- cgit v1.2.3