metaWeblog api in typo fails on some posts
Posted by Jim Morris on Sat Jun 03 23:32:02 -0700 2006
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 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.
Update, even with the latest typo edge, rails still needs to be patched, but it seems they are not on edge rails either.