Skip to content

Boundary sometimes contains invalid '/' character when using "fetch + FormData" to post. #11416

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

Closed
jaggerwang opened this issue Dec 12, 2016 · 13 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@jaggerwang
Copy link

jaggerwang commented Dec 12, 2016

Description

After upgrade RN from 0.35 to 0.39, I got "mime: invalid media parameter" error from my golang server. This error not shows everytime, and it takes me a couple of days to figured out the reason. It is because the form multipart boundary contains invalid '/' character. It waste me a lot of time!!!

It is such a serious problem, can someone fixed it quickly?

Additional Information

  • React Native version: 0.39.0
  • Platform: iOS
  • Operating System: macOS
@lacker
Copy link
Contributor

lacker commented Dec 17, 2016

How did you send this post request to your server? It is not clear to me that this is a React Native problem without getting more information.

@jaggerwang
Copy link
Author

jaggerwang commented Dec 18, 2016

POST /postLike/create HTTP/1.1
Host: api.zqc.dev
Content-Type: multipart/form-data; boundary=BHtyypVdlQVkn6tXeVfwQxmLXQhp4ryB45X0XBZC0CFLiNnkacJs9AytpU8ctvDd_r
Cache-Control: no-cache

--BHtyypVdlQVkn6tXeVfwQxmLXQhp4ryB45X0XBZC0CFLiNnkacJs9AytpU8ctvDd_r
content-disposition: form-data; name="postId"

580ad5456b09330013f0b663
--BHtyypVdlQVkn6tXeVfwQxmLXQhp4ryB45X0XBZC0CFLiNnkacJs9AytpU8ctvDd_r--

When boundary contains "/", the golang server will complain "mime: invalid media parameter". I've already fixed locally, and see somebody else have made a pull request. It should be merged quickly.

@drewtunes
Copy link
Contributor

This is an issue when using a Node.JS Express backend as well. Forward slashes do not follow the RFC specification. See this issue for the Express type-parsing module for more information: jshttp/media-typer#1

I'm wrapping the boundary parameter in quotes to get around this for now. Can someone confirm this is a new issue? I can't believe I haven't run into it before, but it just started with 0.39 for us.

cc @seanj

@drewtunes
Copy link
Contributor

Why was this closed?

@jaggerwang
Copy link
Author

@cava23 , There is already has a same issue about this, and a pull request. So I closed.

@drewtunes
Copy link
Contributor

drewtunes commented Jan 12, 2017 via email

@jaggerwang
Copy link
Author

Duplicated as issue #7564

@jaggerwang
Copy link
Author

It's still exist in 0.40, Why not merge? It's a so serious problem and the fix is very simple.

Just remove the '/' in boundaryChars, which exist in file 'RCTNetworking.mm'.

...
static NSString *RCTGenerateFormBoundary()
{
  const size_t boundaryLength = 70;
  const char *boundaryChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_./";
...

@jaggerwang jaggerwang reopened this Jan 16, 2017
@latte-diygame
Copy link

I hava same issue and it is not merged in 0.41 pre-release.
I spent about 2 days with this issue.
Why not merge?

@alexanderjarvis
Copy link

Also hitting this issue as a regression since previous releases.

@latte-diygame
Copy link

i solved this issue with following.

Thanks to @jaggerwang

// 'RCTNetworking.mm' file
static NSString *RCTGenerateFormBoundary()
{
    const size_t boundaryLength = 70;
    // Remove '/' in boundaryChars !!!
    const char *boundaryChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_./";

    ...
}

@mienaikoe
Copy link

mienaikoe commented Apr 27, 2017

Hitting this issue as well. Not really a fan of fixing code inside of react-native. I'd have to tell all my devs to do this.

@hramos
Copy link
Contributor

hramos commented Jul 20, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Jul 20, 2017
@hramos hramos closed this as completed Jul 20, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants