Skip to content

Commit

Permalink
Fix bugs caused by unicode characters in Dropbox-API-Args header
Browse files Browse the repository at this point in the history
  • Loading branch information
qimingyuan committed Dec 9, 2015
1 parent 71c9199 commit 68e2e7e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 26 deletions.
21 changes: 0 additions & 21 deletions Dropbox.Api/Babel/IEncodable.cs

This file was deleted.

11 changes: 9 additions & 2 deletions Dropbox.Api/Babel/JsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ private JsonWriter(JsonTextWriter writer)
/// <param name="encodable">The object to write.</param>
/// <param name="encoder">The encoder.</param>
/// <returns>The encoded object as a JSON string.</returns>
public static string Write<T>(T encodable, IEncoder<T> encoder)
public static string Write<T>(T encodable, IEncoder<T> encoder, bool escapeNonAscii = false)
{
var builder = new StringBuilder();
var writer = new JsonWriter(new JsonTextWriter(new StringWriter(builder)));
var textWriter = new JsonTextWriter(new StringWriter(builder));

if (escapeNonAscii)
{
textWriter.StringEscapeHandling = StringEscapeHandling.EscapeNonAscii;
}

var writer = new JsonWriter(textWriter);
encoder.Encode(encodable, writer);

var json = builder.ToString();
Expand Down
2 changes: 1 addition & 1 deletion Dropbox.Api/Dropbox.Api.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>$id$</id>
<version>2.0.2</version>
<version>2.0.3</version>
<title>Dropbox v2 API Beta</title>
<authors>Dropbox Inc</authors>
<owners>Dropbox Inc</owners>
Expand Down
4 changes: 2 additions & 2 deletions Dropbox.Api/DropboxRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ async Task<TResponse> ITransport.SendUploadRequestAsync<TRequest, TResponse, TEr
IDecoder<TResponse> resposneDecoder,
IDecoder<TError> errorDecoder)
{
var serializedArg = JsonWriter.Write(request, requestEncoder);
var serializedArg = JsonWriter.Write(request, requestEncoder, true);
var res = await this.RequestJsonStringWithRetry(host, route, RouteStyle.Upload, serializedArg, body);

if (res.IsError)
{
throw ApiException<TError>.Decode(res.ObjectResult, errorDecoder);
Expand Down

0 comments on commit 68e2e7e

Please sign in to comment.