question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong encoding of `filename` parameter on FormData

See original GitHub issue

https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L74

When appending a File object to a FormData instance, the filename parameter is set as is defined in the file name attribute, throwing an exception if it includes non-ASCII characters. According to the spec, it must be encoded as ISO-8859-1, and ideally, also have a filename* parameter with the name encoded as rfc-5987, so full Unicode characters can be used in the filename. To sanitize the filename parameter to be ISO-8859-1, maybe the windows-1252 npm module could be used…

Environment

Environment:
  OS: Linux 4.13
  Node: 9.5.0
  Yarn: Not Found
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: N/A
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: ^16.2.0 => 16.2.0
  react-native: ^0.54.0 => 0.54.0

Expected Behavior

FormData instance would be able to encode a File object (in fact, a React Native “blob”) with non-ASCII characters on its name (more exactly, spanish tildes).

Actual Behavior

screenshot_2018-03-07-11-32-30

Steps to Reproduce

  1. create a FormData instance
  2. append a File object or ReactNative “blob” with non-ASCII characters in the name
  3. send the FormData using fetch()
  4. crash

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
react-native-botcommented, Mar 15, 2018

This issue was marked as lacking information required by the issue template. There has been no activity on this issue for a while, so I will go ahead and close it.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

If you are the author of this issue and you believe this issue was closed in error (i.e. you have edited your issue to ensure it meets the template requirements), please let us know.

0reactions
AlexandrDobrovolskiycommented, Oct 2, 2018

same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong encoding of filename parameter on FormData #18486
When appending a File object to a FormData instance, the filename parameter is set as is defined in the file name attribute, ...
Read more >
Java for Web - Multipart/form-data file with wrong encoding
The problem is that investigating this type of issue is very tricky, since there are many points in the code where the encoding...
Read more >
Encoding problems when using multipart/form-data - Forums
The problem is, when the text contains special characters I get weird output - as if the request parameters aren't decoded using UTF-8....
Read more >
"does not conform to the specification for multipart/form-data ...
Solution: There is a semicolon after the “filename” parameter of the file and this will lead to Asana not being able to parse...
Read more >
RFC 7578 - Returning Values from Forms: multipart/form-data
The Charset Parameter for "text/plain" Form Data; 4.6. ... use multipart/form-data with file names directly encoded including octets outside the US-ASCII ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found