Ticket #130 (assigned defect)

Opened 2 years ago

Last modified 20 months ago

String comparison

Reported by: leandronunes Owned by: ser
Priority: highest Milestone:
Component: Other Version: 3.1.4
Severity: blocker Keywords:
Cc: Ruby version: 1.8.5
Operating system: Linux

Description

I was working in a project using web service on rails. I had a problem with a client of this web service because It was getting the a wrong result add the application crashes.

Searching the problem I found a bug in REXML on file:

/usr/lib/ruby/1.8/rexml/encoding.rb

On line 31 with the content bellow.

raise ArgumentError?, "Bad encoding name #@encoding" unless @encoding =~ /[\w-]+$/

My app always raise the error but when I look into the encoding variable I saw the string. "\"UTF-8\"", so the string never match with the regular expression /[\w-]+$/

I suggest replace this line with the code:

raise ArgumentError?, "Bad encoding name #@encoding" unless @encoding.gsub('"',) =~ /[\w-]+$/

Change History

  Changed 2 years ago by rubys

A test case would be appreciated.

in reply to: ↑ description   Changed 20 months ago by ser

  • status changed from new to assigned

Replying to leandronunes:

My app always raise the error but when I look into the encoding variable I saw the string. "\"UTF-8\"", so the string never match with the regular expression /[\w-]+$/

Are you saying that, in your XML document, your encoding is something like this:

<?xml version='1.0' encoding='"UTF-8"'?>

Can you provide a small sample of your document that causes this error?

Note: See TracTickets for help on using tickets.