1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
shyouhei 2011-05-27 02:34:23 +00:00
parent e65e24bd27
commit 42f704a8fa
2 changed files with 4 additions and 1 deletions

View file

@ -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

View file

@ -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 )"