Patching Ruby for WWMD
I recently had to deal again with ASP.NET code. Yep. Poor me. This also means poking around in ASP.NET viewstates to search for interesting data, which is made easier by Mike Tracey’s WWMD and its viewstate decoder, thank goodness.
So I was really annoyed when the .to_xml.pp() method on the viewstate object bailed out on me with the following lovely stack trace:
NoMethodError: private method `gsub' called for 43:Fixnum from /usr/lib/ruby/1.8/rexml/text.rb:293:in `normalize' from /usr/lib/ruby/1.8/rexml/element.rb:1085:in `=' from /usr/lib/ruby/1.8/rexml/element.rb:587:in `add_attribute' from ./wwmd/viewstate/vs_stubs/vs_stub_helpers.rb:29:in `to_xml' [...]
Turns out, there’s a bug in the rexml library, as can be seen in this post in the Ruby forum. The fix proposed by Matz himself works (its as simple as adding a “to_s” to a Fixnum object in the code), so I patched my current Ruby installation, which is rather annoying. I hope this gets fixed with the next Ruby package Arch provides.