Ticket #100 (closed defect: fixed)

Opened 18 months ago

Last modified 14 months ago

Can't recognize encoding in check_encoding method

Reported by: denest Owned by: ser
Priority: normal Milestone: 3.1.7
Component: Other Version: 3.1.4
Severity: blocker Keywords:
Cc: Ruby version: 1.8.5
Operating system: All

Description (last modified by ser) (diff)

Hi,

in REXML::Encoding modul the check_encoding method can't give the right encoding other that utf-8 and utf-16. In the regexp match there should be \1 instead of the first \2 and the method should return $3 instead of $1. The right code is:

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      
  str =~ /^\s*<?xml\s*version\s*=\s*(['"]).*\1\s*encoding\s*=\s*(["'])(.*?)\2/um        
  return $3.upcase if $3      
  return UTF_8    
end

Change History

Changed 14 months ago by ser

  • milestone set to 3.1.8

Changed 14 months ago by ser

  • status changed from new to assigned
  • description modified (diff)

Changed 14 months ago by ser

  • status changed from assigned to closed
  • resolution set to fixed
  • milestone changed from 3.1.8 to 3.1.7

This was fixed at some point before the milestone:3.1.7 release.

Note: See TracTickets for help on using tickets.