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

Revert r37439 and r37441

r37439:
	* lib/rexml/xmldecl.rb (REXML::XMLDecl): Stop using REXML::Encoding
	  module because XMLDecl doesn't convert encoding. This causes
	  removing XML encoding name normalization (encoding.upcase).
	  Encoding name in XML declaration is what user specifies.
	  I think this is reasonable change.
	* test/rexml/test_xml_declaration.rb: Add tests for the above change.

r37441:
	* test/rexml/test_core.rb (Tester#test_ticket_88): Follow the
	  change that encoding name in XML declaration isn't normalized.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2012-11-03 04:46:06 +00:00
parent 4aca275e9c
commit bdbc8c5b74
4 changed files with 9 additions and 32 deletions

View file

@ -10,11 +10,6 @@ Sat Nov 3 13:01:02 2012 Kouhei Sutou <kou@cozmixng.org>
Fix a test that expects encoding in XML declaration is changed by Fix a test that expects encoding in XML declaration is changed by
Output's encoding. It is dropped feature. Output's encoding. It is dropped feature.
Sat Nov 3 12:54:13 2012 Kouhei Sutou <kou@cozmixng.org>
* test/rexml/test_core.rb (Tester#test_ticket_88): Follow the
change that encoding name in XML declaration isn't normalized.
Sat Nov 3 12:49:45 2012 Kouhei Sutou <kou@cozmixng.org> Sat Nov 3 12:49:45 2012 Kouhei Sutou <kou@cozmixng.org>
* lib/rexml/document.rb (REXML::Document#write): Document encoding * lib/rexml/document.rb (REXML::Document#write): Document encoding
@ -25,15 +20,6 @@ Sat Nov 3 12:49:45 2012 Kouhei Sutou <kou@cozmixng.org>
encoding. encoding.
* test/rexml/test_document.rb: Update tests for the above change. * test/rexml/test_document.rb: Update tests for the above change.
Sat Nov 3 12:36:35 2012 Kouhei Sutou <kou@cozmixng.org>
* lib/rexml/xmldecl.rb (REXML::XMLDecl): Stop using REXML::Encoding
module because XMLDecl doesn't convert encoding. This causes
removing XML encoding name normalization (encoding.upcase).
Encoding name in XML declaration is what user specifies.
I think this is reasonable change.
* test/rexml/test_xml_declaration.rb: Add tests for the above change.
Sat Nov 3 12:18:35 2012 Masaki Matsushita <glass.saga@gmail.com> Sat Nov 3 12:18:35 2012 Masaki Matsushita <glass.saga@gmail.com>
* array.c (recursive_equal): fix not to make invalid pointers when * array.c (recursive_equal): fix not to make invalid pointers when

View file

@ -4,6 +4,8 @@ require 'rexml/source'
module REXML module REXML
# NEEDS DOCUMENTATION # NEEDS DOCUMENTATION
class XMLDecl < Child class XMLDecl < Child
include Encoding
DEFAULT_VERSION = "1.0"; DEFAULT_VERSION = "1.0";
DEFAULT_ENCODING = "UTF-8"; DEFAULT_ENCODING = "UTF-8";
DEFAULT_STANDALONE = "no"; DEFAULT_STANDALONE = "no";
@ -11,7 +13,7 @@ module REXML
STOP = '\?>'; STOP = '\?>';
attr_accessor :version, :standalone attr_accessor :version, :standalone
attr_reader :encoding, :writeencoding, :writethis attr_reader :writeencoding, :writethis
def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil) def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil)
@writethis = true @writethis = true
@ -51,7 +53,7 @@ module REXML
def ==( other ) def ==( other )
other.kind_of?(XMLDecl) and other.kind_of?(XMLDecl) and
other.version == @version and other.version == @version and
other.encoding.upcase == self.encoding.upcase and other.encoding == self.encoding and
other.standalone == @standalone other.standalone == @standalone
end end
@ -66,13 +68,14 @@ module REXML
end end
alias :stand_alone? :standalone alias :stand_alone? :standalone
alias :old_enc= :encoding=
def encoding=( enc ) def encoding=( enc )
if enc.nil? if enc.nil?
@encoding = "UTF-8" self.old_enc = "UTF-8"
@writeencoding = false @writeencoding = false
else else
@encoding = enc self.old_enc = enc
@writeencoding = true @writeencoding = true
end end
self.dowrite self.dowrite

View file

@ -1312,9 +1312,9 @@ EOL
def test_ticket_88 def test_ticket_88
doc = REXML::Document.new("<?xml version=\"1.0\" encoding=\"shift_jis\"?>") doc = REXML::Document.new("<?xml version=\"1.0\" encoding=\"shift_jis\"?>")
assert_equal("<?xml version='1.0' encoding='shift_jis'?>", doc.to_s) assert_equal("<?xml version='1.0' encoding='SHIFT_JIS'?>", doc.to_s)
doc = REXML::Document.new("<?xml version = \"1.0\" encoding = \"shift_jis\"?>") doc = REXML::Document.new("<?xml version = \"1.0\" encoding = \"shift_jis\"?>")
assert_equal("<?xml version='1.0' encoding='shift_jis'?>", doc.to_s) assert_equal("<?xml version='1.0' encoding='SHIFT_JIS'?>", doc.to_s)
end end
def test_ticket_85 def test_ticket_85

View file

@ -31,16 +31,4 @@ class TestXmlDeclaration < Test::Unit::TestCase
assert_kind_of(REXML::XMLDecl, @root.previous_sibling.previous_sibling) assert_kind_of(REXML::XMLDecl, @root.previous_sibling.previous_sibling)
assert_kind_of(REXML::Element, @xml_declaration.next_sibling.next_sibling) assert_kind_of(REXML::Element, @xml_declaration.next_sibling.next_sibling)
end end
def test_equal
lower_encoding_xml_decl = REXML::XMLDecl.new("1.0", "utf-8")
upper_encoding_xml_decl = REXML::XMLDecl.new("1.0", "UTF-8")
assert_equal(lower_encoding_xml_decl, upper_encoding_xml_decl)
end
def test_encoding_is_not_normalized
lower_encoding_xml_decl = REXML::XMLDecl.new("1.0", "utf-8")
assert_equal("<?xml version='1.0' encoding='utf-8'?>",
lower_encoding_xml_decl.to_s)
end
end end