Skip to content

Wrong encoding of filename parameter on FormData #18486

@piranna

Description

@piranna

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPlatform: LinuxBuilding on Linux.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions