vhson / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

[PATCH] A file which has specific mutibytes character name can't be uploaded by ResumableUploader #595

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Prepare "世.txt" file.
2. Upload the file by same way with the sample code.
https://developers.google.com/google-apps/documents-list/#uploading_a_new_docume
nt_or_file_with_both_metadata_and_content

What is the expected output? What do you see instead?

The file should be uploaded. 
But I got the ArgumentException exception from 
System.Net.WebHeaderCollection.CheckBadChars.

What version of the product are you using? On what operating system?

1195 / Windows 7 64bit / C++/CLI

Please provide any additional information below.

UTF-8 characters 0xe69c80~0xe69c90 causes the same issue.

The file name will go the slug header and we should Uri.EscapeDataString the 
slug string.

Index: resumableupload.cs
===================================================================
--- resumableupload.cs  (リビジョン 1195)
+++ resumableupload.cs  (作業コピー)
@@ -689,7 +689,7 @@
             long contentLength,
             string httpMethod) {
             HttpWebRequest request = authentication.CreateHttpWebRequest(httpMethod, target);
-            request.Headers.Set(GDataRequestFactory.SlugHeader, slug);
+            request.Headers.Set(GDataRequestFactory.SlugHeader, 
Uri.EscapeDataString(slug));
             request.Headers.Set(GDataRequestFactory.ContentOverrideHeader, contentType);
             if (contentLength != -1) {
                 request.Headers.Set(GDataRequestFactory.ContentLengthOverrideHeader, contentLength.ToString());

Original issue reported on code.google.com by chitor...@gmail.com on 6 Jun 2012 at 3:02

GoogleCodeExporter commented 9 years ago
Thanks for reporting the issue, I patched the resumable uploader component to 
apply the correct encoding to the slug header:

http://code.google.com/p/google-gdata/source/detail?r=1197

Original comment by ccherub...@google.com on 6 Jun 2012 at 6:02