Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong encoding of filename parameter on FormData #18486

Closed
piranna opened this issue Mar 21, 2018 · 11 comments
Closed

Wrong encoding of filename parameter on FormData #18486

piranna opened this issue Mar 21, 2018 · 11 comments
Labels
Bug Platform: Linux Building on Linux. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@piranna
Copy link

piranna commented Mar 21, 2018

headers['content-disposition'] += '; filename="' + value.name + '"';

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
@react-native-bot react-native-bot added the Platform: Linux Building on Linux. label Mar 21, 2018
@stale
Copy link

stale bot commented Jun 19, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 19, 2018
@piranna
Copy link
Author

piranna commented Jun 19, 2018

This issue is still happening in latest version of React Native and needs some community attention. It could be a good candidate for the "Good first issue" label, too.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 19, 2018
@stale
Copy link

stale bot commented Sep 17, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Sep 17, 2018
@piranna
Copy link
Author

piranna commented Sep 17, 2018

This is still happening in latest version.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Sep 17, 2018
@elliscwc
Copy link

elliscwc commented Dec 5, 2018

Also having this issue when user trying to upload filename with korean/chinese words.
I think react-native is using okhttp, they have a solution for this: square/okhttp#4296 but not yet included in react-native, hope this will get attention it needed.

@deepsh4h
Copy link

How do I handle this in RN ?

@frenberg
Copy link

How do I handle this in RN ?

In my case I added an encodeURIComponent(filename) but I suppose it depends on if you have access to the backend or if you can live with the consequence of ugly filenames

@stale
Copy link

stale bot commented Aug 2, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 2, 2019
@piranna
Copy link
Author

piranna commented Aug 2, 2019

This is still happening in latest version.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 2, 2019
@stale
Copy link

stale bot commented Oct 31, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 31, 2019
@stale
Copy link

stale bot commented Nov 7, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Nov 7, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Nov 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Linux Building on Linux. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

6 participants