mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c032c5bc9a
commit
69eedf6a18
3 changed files with 25 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
|||
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>
|
||||
|
||||
* array.c (recursive_equal): fix not to make invalid pointers when
|
||||
|
|
|
@ -4,8 +4,6 @@ require 'rexml/source'
|
|||
module REXML
|
||||
# NEEDS DOCUMENTATION
|
||||
class XMLDecl < Child
|
||||
include Encoding
|
||||
|
||||
DEFAULT_VERSION = "1.0";
|
||||
DEFAULT_ENCODING = "UTF-8";
|
||||
DEFAULT_STANDALONE = "no";
|
||||
|
@ -13,7 +11,7 @@ module REXML
|
|||
STOP = '\?>';
|
||||
|
||||
attr_accessor :version, :standalone
|
||||
attr_reader :writeencoding, :writethis
|
||||
attr_reader :encoding, :writeencoding, :writethis
|
||||
|
||||
def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil)
|
||||
@writethis = true
|
||||
|
@ -57,7 +55,7 @@ module REXML
|
|||
def ==( other )
|
||||
other.kind_of?(XMLDecl) and
|
||||
other.version == @version and
|
||||
other.encoding == self.encoding and
|
||||
other.encoding.upcase == self.encoding.upcase and
|
||||
other.standalone == @standalone
|
||||
end
|
||||
|
||||
|
@ -72,14 +70,13 @@ module REXML
|
|||
end
|
||||
|
||||
alias :stand_alone? :standalone
|
||||
alias :old_enc= :encoding=
|
||||
|
||||
def encoding=( enc )
|
||||
if enc.nil?
|
||||
self.old_enc = "UTF-8"
|
||||
@encoding = "UTF-8"
|
||||
@writeencoding = false
|
||||
else
|
||||
self.old_enc = enc
|
||||
@encoding = enc
|
||||
@writeencoding = true
|
||||
end
|
||||
self.dowrite
|
||||
|
|
|
@ -31,4 +31,16 @@ class TestXmlDeclaration < Test::Unit::TestCase
|
|||
assert_kind_of(REXML::XMLDecl, @root.previous_sibling.previous_sibling)
|
||||
assert_kind_of(REXML::Element, @xml_declaration.next_sibling.next_sibling)
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue