You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Uploaded file has incorrectly encoded filename if this filename has non-ASCII characters #1828
Describe the bug
If you try to upload a file that has non-ASCII characters in its filename (eg. ÄÖäö.jpg), then Content-Disposition is encoded to smth like "=?utf-8?B?S29hbGHDhMOWw6TDti5qcGc=?="
Actual behavior
fileContent.Headers.ContentDisposition - form-data; name="file"; filename="=?utf-8?B?S29hbGHDhMOWw6TDti5qcGc=?="
Notes
For a file like Koala.jpg fileContent.Headers.ContentDisposition is form-data; name="file"; filename="Koala.jpg".
Initially, it's an issue with ContentDispositionHeaderValue (microsoft/referencesource#140), but I don't know how to fix it there.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I'd like to know more about the issue itself. Why is the current behaviour wrong? We have an integrated test that sends the file to an echo upload API, and it works with both ASCII and non-ASCII characters. Do you have a specific server that for some reason is unable to understand web standards?
I was not sure that this was the expected
behaviour. I was thinking that something was wrong with my code because
when the same file is uploaded via postman client to the server, the
filename is preserved with its foreign characters.
On Thu, Jul 7, 2022 at 6:27 PM Alexey Zimarev ***@***.***> wrote:
I'd like to know more about the issue itself. Why is the current behaviour
wrong? We have an integrated test that sends the file to an echo upload
API, and it works with both ASCII and non-ASCII characters. Do you have a
specific server that for some reason is unable to understand web standards?
—
Reply to this email directly, view it on GitHub
<#1828 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANV5QQEV3MMBLZKQVYZ6F7LVS3H2DANCNFSM5SQXF63A>
.
You are receiving this because you commented.Message ID:
***@***.***>
Normally, the server should be able to decide the MIME-encoded filename. The current implementation, however, doesn't support the filename* parameter, which is the UTF-8 encoded filename. It worked before. I think the reason for using the current code is that the default values aren't enclosed in quotes and it broke some other servers.
I wish that people who develop servers spend some time reading the docs about how this all should work... Checking some other things now.
Ok, I am sorry to say but your code doesn't work. I will create another PR. When I made it work as you expected it to work (without encoding), the tests fail as the ASP.NET Core WebAPI doesn't like it. These tests only passed because your code didn't work. What you got, in fact, is the filename* parameter in the header, which is currently disabled by default.
Activity
asynchk commentedon Apr 8, 2022
Thanks for raising the issue I am facing the same problem
stale commentedon Jun 23, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
repo-ranger commentedon Jun 23, 2022
PooraniPerumal commentedon Jul 5, 2022
I am facing the same issue.
alexeyzimarev commentedon Jul 7, 2022
I'd like to know more about the issue itself. Why is the current behaviour wrong? We have an integrated test that sends the file to an echo upload API, and it works with both ASCII and non-ASCII characters. Do you have a specific server that for some reason is unable to understand web standards?
PooraniPerumal commentedon Jul 7, 2022
alexeyzimarev commentedon Jul 7, 2022
Normally, the server should be able to decide the MIME-encoded filename. The current implementation, however, doesn't support the
filename*parameter, which is the UTF-8 encoded filename. It worked before. I think the reason for using the current code is that the default values aren't enclosed in quotes and it broke some other servers.I wish that people who develop servers spend some time reading the docs about how this all should work... Checking some other things now.
alexeyzimarev commentedon Jul 7, 2022
Ok, I am sorry to say but your code doesn't work. I will create another PR. When I made it work as you expected it to work (without encoding), the tests fail as the ASP.NET Core WebAPI doesn't like it. These tests only passed because your code didn't work. What you got, in fact, is the
filename*parameter in the header, which is currently disabled by default.Fixes #1828
alexeyzimarev commentedon Jul 7, 2022
You can try the latest preview and add the file parameter like this:
I think it won't work, but it actually does what you wanted.
You can also try:
and I expect it to solve the actual issue.
Fixes restsharp#1828 (restsharp#1887)