summaryrefslogtreecommitdiff
path: root/test/rexml/test_document.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-14 13:11:11 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-14 13:11:11 +0000
commit46ff009168cfb29b473bc37d38b64719ad9e6526 (patch)
tree90ac37a9ec3447c10b246bef3f9da1b5a4d66ceb /test/rexml/test_document.rb
parent55f7857a7758102eb512eaa7aca3d2855fb797da (diff)
* lib/rexml/source.rb: force_encoding("UTF-8") when the input
is already UTF-8. patched by Kouhei Sutou [ruby-core:23404] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rexml/test_document.rb')
-rw-r--r--test/rexml/test_document.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb
index 1ee1a1d..ab0b1e4 100644
--- a/test/rexml/test_document.rb
+++ b/test/rexml/test_document.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require "rexml/document"
require "test/unit"
@@ -83,6 +85,18 @@ EOF
REXML::Document.entity_expansion_limit = 10000
end
+ def test_tag_in_cdata_with_not_ascii_only_but_ascii8bit_encoding_source
+ tag = "<b>...</b>"
+ message = "こんにちは、世界!" # Hello world! in Japanese
+ xml = <<EOX
+<?xml version="1.0" encoding="UTF-8"?>
+<message><![CDATA[#{tag}#{message}]]></message>
+EOX
+ xml.force_encoding(Encoding::ASCII_8BIT)
+ doc = REXML::Document.new(xml)
+ assert_equal("#{tag}#{message}", doc.root.children.first.value)
+ end
+
def test_xml_declaration_standalone
bug2539 = '[ruby-core:27345]'
doc = REXML::Document.new('<?xml version="1.0" standalone="no" ?>')