diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-28 12:31:20 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-28 12:31:20 +0000 |
commit | 2a42c1bd3a8fcaa59f778070bff0eac60757ced3 (patch) | |
tree | bcd9a2aa1f23d4f35bfd7fd30ad6ecc58303d43a /lib/rexml/parsers/baseparser.rb | |
parent | 100b3be9ae7f6ad0af53dd87d0e9706df6e813c3 (diff) |
* lib/rexml/source.rb (REXML::IOSource#initialize): Reduce
@line_break initialize code. It should be done only in #encoding=.
* lib/rexml/parsers/baseparser.rb: Don't set UTF-16 encoding to
source by encoding="UTF-16" in XML declaration because UTF-16XX
source encoding should be set in Source#initialize or
IOSource#intialize. They should handle BOM. Parser should not
consider about it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/parsers/baseparser.rb')
-rw-r--r-- | lib/rexml/parsers/baseparser.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb index ebffdaa8c7..dc4a1c8bee 100644 --- a/lib/rexml/parsers/baseparser.rb +++ b/lib/rexml/parsers/baseparser.rb @@ -212,7 +212,9 @@ module REXML version = version[1] unless version.nil? encoding = ENCODING.match(results) encoding = encoding[1] unless encoding.nil? - @source.encoding = encoding + if need_source_encoding_update?(encoding) + @source.encoding = encoding + end standalone = STANDALONE.match(results) standalone = standalone[1] unless standalone.nil? return [ :xmldecl, version, encoding, standalone ] @@ -493,6 +495,13 @@ module REXML end rv end + + private + def need_source_encoding_update?(xml_declaration_encoding) + return false if xml_declaration_encoding.nil? + return false if /\AUTF-16\z/i =~ xml_declaration_encoding + true + end end end end |