Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8806 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Hash.from_xml double-unescapes entities

Reported by: Ezran Assigned to: core
Priority: normal Milestone: 1.x
Component: ActiveSupport Version: edge
Severity: normal Keywords: hash from_xml escaping verified
Cc:

Description

Hash.from_xml will unescape entities in the actual content values rather than returning the original values.

This is because typecast_xml_value calls translate_xml_entities on values even though XmlSimple already did the unescaping.

Simple test:

>> address = { 'in_xml' => '<intersection>Fourth &amp; Main</intersection>' }
=> {"in_xml"=>"<intersection>Fourth &amp; Main</intersection>"}
>> Hash.from_xml(address.to_xml)['hash']
=> {"in_xml"=>"<intersection>Fourth & Main</intersection>"}

As you can see, trying to store actual XML inside a hash will fail because the from_xml double-unescaping will turn it into invalid XML.

Attachments

fix_hash_from_xml_escaping.diff (2.2 kB) - added by Ezran on 06/29/07 16:07:16.
Patch to fix unescaping and tests to verify.

Change History

06/29/07 16:07:16 changed by Ezran

  • attachment fix_hash_from_xml_escaping.diff added.

Patch to fix unescaping and tests to verify.

08/30/07 09:24:05 changed by deepblue

+1 for this patch.

08/30/07 09:26:22 changed by iasandcb

+1 as well.

08/30/07 09:30:51 changed by jasonpa

+1 must be ...

09/17/07 17:27:13 changed by Ezran

  • keywords changed from hash from_xml escaping to hash from_xml escaping verified.

09/17/07 21:32:03 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [7505]) Hash#to_xml doesn't double-unescape. Closes #8806.