0

We recently moved to rails 3.2.13. We use ActiveResource to call a web service. ActiveResoure will generate the xml payload. We noticed that the new xml doesn't escape unicode character. For example:

  &ltname&gt C:\Documents and Settings\All Users\testütestdev1.txt &lt/name&gt

In rails 2.3, it will escape ü to ü :

  &ltname&gt C:\Documents and Settings\All Users\testütestdev1.txt &ltname&gt

After some investigation. It looks like it is due to ActiveSuppport to_xml method which doesn't escape unicode character. Has anyone had this issue and know how to solve it?

DrChanimal
  • 681
  • 5
  • 10

1 Answers1

1

You could use Rack::Utils for that

> Rack::Utils.escape("  <name> C:\Documents and Settings\All Users\testütestdev1.txt </name>")
#=> "++%3Cname%3E+C%3ADocuments+and+SettingsAll+Users%09est%C3%BCtestdev1.txt+%3C%2Fname%3E"

> Rack::Utils.unescape(_)
#=> "  <name> C:Documents and SettingsAll Users\testütestdev1.txt </name>"
shime
  • 8,746
  • 1
  • 30
  • 51
  • But the problem is that we can't do the escape myself because we are using active_resource to make a web service call which will generate the xml. – DrChanimal Apr 09 '13 at 23:50