Hi,

I've been working on a problem we've been having with our app. In essence we have a controller that receives a blob of binary data (as a raw post) and processes it (this data happens to be a marshaled ruby object but that's not relevant here). The problem was that occasionally the last byte of the post body was going missing. I tracked it down to the following method in action_controller/cgi_ext/ raw_post_data_fix:

def read_body(content_length)
    stdinput.binmode if stdinput.respond_to?(:binmode)
    content = stdinput.read(content_length) || ''
    # Fix for Safari Ajax postings that always append \000
    content.chop! if content[-1] == 0
    content.gsub!(/&_=$/, '')
    env_table['RAW_POST_DATA'] = content.freeze
end

I don't know the history behind the truncation of the last byte if it is nil, but surely there has to be a better way to do this?

Fred

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to