summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-27 02:34:23 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-27 02:34:23 +0000
commit42f704a8faee3c60f2717430f1acbfbe97953491 (patch)
tree93b451ccdbbbcd213b7df7492db19eb8af28d659
parente65e24bd2747203862e6773d7c74996d58e92f4e (diff)
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@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/rexml/text.rb2
-rw-r--r--test/rexml/test_core.rb3
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb
index 05d5341..6623c0c 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 d10c1bc..d6d6271 100644
--- a/test/rexml/test_core.rb
+++ b/test/rexml/test_core.rb
@@ -349,6 +349,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 &lt; ( 1 &amp; 1 )"