Wolfmans Howlings

A programmers Blog about Ruby, Rails and a few other issues

metaWeblog api in typo fails on some posts

Posted by Jim Morris Sun, 04 Jun 2006 06:32:00 GMT

I was using a ruby script to post my blogs from the command line, and it used the xmlrpc/client which would occasionally fail with this error…

/usr/local/lib/ruby/1.8/xmlrpc/client.rb:546:in `do_rpc': HTTP-Error: 500 Internal Server Error  (RuntimeError)
    from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:420:in `call2'
    from /usr/local/lib/ruby/1.8/xmlrpc/client.rb:410:in `call'
    from send2blog.rb:103

This was annoying, so I did some sleuthing and it turns out there were various apparently unrelated bugs posted about this in the typo trac, and in rails. I noticed it seemed to be fixed in Rails edge so I found the patch and applied it locally to my typo’s version of rails, and now I can post all my blogs from the command line again.

The problem was with posts containing && or << etc which seeing as I was posting a lot of ruby code most of my blogs had.

  • The relevant ticket is #538
  • The relevant rails ticket is #4955

The fix is a one line addition to vendor/rails/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb on line 48 the patch is…

Index: actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
===================================================================
--- actionpack/lib/action_controller/cgi_ext/cgi_methods.rb     (revision 4324)
+++ actionpack/lib/action_controller/cgi_ext/cgi_methods.rb     (working copy)
@@ -45,6 +45,7 @@
       parsed_params = {}

       for key, value in params
+        next if key.nil?
     value = [value] if key =~ /.*[]$/
     unless key.include?('[')
       # much faster to test for the most common case first (GET)

This seems to work for rails versions >= 1.0, although it is already patched in edge rails.

Posted in ,  | Tags ,  | 1 comment | no trackbacks

Comments

  1. wolfman said 3 months later:

    Update, even with the latest typo edge, rails still needs to be patched, but it seems they are not on edge rails either.

Trackbacks

Use the following link to trackback from your own site:
http://blog.wolfman.com/articles/trackback/26

(leave url/email »)

   Comment Markup Help Preview comment