Skip to content

Uploaded file has incorrectly encoded filename if this filename has non-ASCII characters #1828

@inna-artiushenko

Description

@inna-artiushenko

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=?="

To Reproduce

  1. Set a breakpoint to https://github.com/restsharp/RestSharp/blob/dev/src/RestSharp/Request/RequestContent.cs#L65
  2. Rename test file Koala.jpg to KoalaÄÖäö.jpg
  3. Change test data (to filename = "KoalaÄÖäö.jpg") and run an upload test eg. Should_upload_from_file
  4. Check fileContent.Headers.ContentDisposition value in RequestContent.AddFiles()

Expected behavior
fileContent.Headers.ContentDisposition - form-data; name="file"; filename="ÄÖäö.jpg"

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions