gerrit/gerrit-httpd
Shawn Pearce 4cee8e9d16 InlineEdit: Fix mangling of non-ASCII characters
atob() does not handle Unicode well.  The decoding routine creates a
Unicode DOM string from the decoded bytes effectively treating the
stream as ISO-8859-1.  This breaks non-ASCII by decomposing characters
into several meaningless "characters".

Instead of decoding base64 in the browser, modify the server to return
base64() BinaryResult as a JSON string if the only value of the Accept
request header is application/json.  RestApi client code currently
always sets "Accept: application/json" in the request, as the browser
JS strongly prefers JSON in the response body.

Relying on the native JavaScript parser in the browser to read and
decode the JSON string is smaller and more efficient than a pure
JavaScript implementation of base64 decoding that supports UTF-8.

Fix the Content-Type used during POST and PUT to document charset is
UTF-8.  The XMLHttpRequest standard requires browsers to always encode
in UTF-8, however the server examines the request's Content-Type
header to extract the charset attribute. Without setting the charset
an arbitrary default encoding was chosen by the server, which may still
mangle a commit message or file during save.

Bug: issue 3093
Change-Id: I549037bfb82aff15bbffc8b4a01e8955ae0ce318
2015-02-05 13:38:53 -08:00
..
src InlineEdit: Fix mangling of non-ASCII characters 2015-02-05 13:38:53 -08:00
BUCK Convert some value classes to AutoValue 2015-01-22 12:15:58 -08:00