diff options
author | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-04 04:50:15 +0000 |
---|---|---|
committer | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-04 04:50:15 +0000 |
commit | 37886ed9a8205673ce073153f762ab05eca13ac5 (patch) | |
tree | d3489b735a95f2870cc14e0fbb01b5933a173951 /lib/rexml/encoding.rb | |
parent | 80018be1fb538641742ccf8f1edfe6ba975a2b95 (diff) |
Fixes a bug in the pretty printer related to an incomplete refactoring.
Fixes another bug related to the formatting code refactoring in 3.1.7
Fixes ticket:99, and adds Henrik's unit test (with minor modifications)
Fixes ticket:102.
Fix provided by kevinj -- thanks! Great job.
Implements namespace validation in the baseparser. This means that, as per
the XML namespace spec, unbound prefixes generate UndefinedNamespaceException.
Also, as per the namespace spec, the 'xml' prefix must be bound to
http://www.w3.org/XML/1998/namespace, and the 'xmlns' prefix must not be declared.
in the XML.
Fix for ticket:115
Fixes a bug in the pretty printer related to an incomplete refactoring.
Merge code cleanups
Fixes another bug related to the formatting code refactoring in 3.1.7
Indentation fix.
lib/rexml/formatters/*.rb: set properties.
lib/rexml/encodings/{ISO-8859-15,CP-1252}.rb: fixed invalid syntax.
lib/rexml/rexml.rb: removed doubled constant.
lib/rexml/rexml.rb: added encoding.
Fixes ticket:110
Missing include for UndefinedNamespaceException was causing errors in some
cases.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@13815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/encoding.rb')
-rw-r--r-- | lib/rexml/encoding.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb index 6cae6b644d..a01763be99 100644 --- a/lib/rexml/encoding.rb +++ b/lib/rexml/encoding.rb @@ -56,8 +56,13 @@ module REXML def check_encoding str # We have to recognize UTF-16, LSB UTF-16, and UTF-8 - return UTF_16 if /\A\xfe\xff/n =~ str - return UNILE if /\A\xff\xfe/n =~ str + if str[0] == 0xfe && str[1] == 0xff + str[0,2] = "" + return UTF_16 + elsif str[0] == 0xff && str[1] == 0xfe + str[0,2] = "" + return UNILE + end str =~ /^\s*<\?xml\s+version\s*=\s*(['"]).*?\1\s+encoding\s*=\s*(["'])(.*?)\2/um return $3.upcase if $3 return UTF_8 |