Project

General

Profile

Actions

Bug #8602

closed

REXML::Element#add_text and REXML::Text#<<

Added by ohai (Ippei Obayashi) over 10 years ago. Updated over 10 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.1.0dev (2013-07-04 trunk 41732) [x86_64-linux]
[ruby-dev:47482]

Description

以下のコードは "foo bar" が出力されることが期待されますが実際には "foo" が出力されます。
require 'rexml/document'
doc = REXML::Document.new("")
doc.root.add_text("foo")
doc.to_s
doc.root.add_text(" bar")
p doc.root.to_s
doc.to_s の部分をコメントアウトすると挙動が変わり "foo bar" が出力されます。

REXML::Element#add_text が呼び出している REXML::Text#<< が内部状態(@string)を変化させているにもかかわらず
キャッシュ(@normalized, @unnormalized)をクリアしていないのが原因だと思われます。

添付したパッチで修正されると思います。


Files

rexml-text-append-fix.patch (317 Bytes) rexml-text-append-fix.patch ohai (Ippei Obayashi), 07/05/2013 03:36 AM
rexml-text-append-test.patch (530 Bytes) rexml-text-append-test.patch ohai (Ippei Obayashi), 07/05/2013 03:36 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0