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

Fix FormData to properly handle appended arrays. #32815

Closed
wants to merge 1 commit into from

Conversation

bang9
Copy link
Contributor

@bang9 bang9 commented Dec 29, 2021

Summary

The Array appended to FormData must be transmitted in the form of a string.
However, it is treated as a file object and transmitted, because typeof Array is 'object' too

In network

form.append('array_name', ['a', 'b', 'c'])

// Browser
// --
// content-disposition: form-data; name='array_name';
//
// a,b,c
// --

// ReactNative
// --
// content-disposition: form-data; name='array_name';
// 
// 
// --

Changelog

[General] [Fixed] - The Array appended to FormData is transmitted as a string

Test Plan

Added test case

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Dec 29, 2021
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 725bffc
Branch: main

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,291,388 +25
android hermes armeabi-v7a 7,625,109 +48
android hermes x86 8,764,225 +46
android hermes x86_64 8,700,779 +39
android jsc arm64-v8a 9,679,731 +0
android jsc armeabi-v7a 8,670,129 +12
android jsc x86 9,638,059 +1
android jsc x86_64 10,232,228 +2

Base commit: 725bffc
Branch: main

@facebook-github-bot
Copy link
Contributor

@charlesbdudley has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@bang9
Copy link
Contributor Author

bang9 commented Mar 3, 2022

Hi @charlesbdudley
Is there anything else I can do help to this PR get merged? :)

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @bang9 in d2e8e7d.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Mar 28, 2022
Saadnajmi pushed a commit to Saadnajmi/react-native-macos that referenced this pull request Jan 15, 2023
Summary:
The Array appended to FormData must be transmitted in the form of a string.
However, it is treated as a file object and transmitted, because `typeof Array` is `'object'` too

In network
```js
form.append('array_name', ['a', 'b', 'c'])

// Browser
// Content-Disposition: form-data; name='array_name';
// a,b,c

// ReactNative
// Content-Disposition: form-data; name='array_name';
//
```

## Changelog
[General] [Fixed] - The Array appended to FormData is transmitted as a string

Pull Request resolved: facebook#32815

Test Plan: Added test case

Reviewed By: lunaleaps

Differential Revision: D33369594

Pulled By: charlesbdudley

fbshipit-source-id: 0b5219a2c9f73cf16665dc417cceb4481428ad4e
@bang9 bang9 deleted the fix/form-data branch November 10, 2023 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants