post-review: correctly handle diff uploads, which contains non-ASCII characters

Review Request #1298 — Created Dec. 14, 2009 and submitted




Previous post-review versions did not correctly generate the Content-Length header sent along with the api/json/reviewrequests/<id>/diff/new/ request as the header's value was calculated based upon the length of the request body in characters instead of bytes. This patch should fix that issue by using the UTF-8 representation of the body for the length calculation.

  1. Looks good. Committed to rbtools master as 8a7c87e.
  1. I've reverted this change, as it's introduced several other problems.
    I'm also confused about how this works. Isn't this the opposite of what we want? The ? character is actually 3 bytes (and therefore a length of 3), but encoding the string to UTF-8 will result in it being represented as a length of 1. This would truncate it.
    Not all things can just be encoded into utf-8 like this, so RBTools is pretty broken as a result. I'd like to get a sample diff from you that demonstrated the truncation problem so I can run some tests and find another solution.