8000 prevent an error when passing a frozen string to REXML::Text.new by misfo · Pull Request #22 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

prevent an error when passing a frozen string to REXML::Text.new #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
  • Loading branch information
misfo committed May 18, 2011
commit 802b5eb598ee3c6fdd897252558823411b1ed768
2 changes: 1 addition & 1 deletion lib/rexml/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def initialize(arg, respect_whitespace=false, parent=nil, raw=nil,
@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
Expand Down
3 changes: 3 additions & 0 deletions test/rexml/test_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ def test_text
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 )"
Expand Down
0