React-native: Boundary sometimes contains invalid '/' character when using "fetch + FormData" to post.

Created on 12 Dec 2016  Â·  13Comments  Â·  Source: facebook/react-native

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
Locked

Most helpful comment

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-_./";
...

All 13 comments

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.

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.

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: https://github.com/jshttp/media-typer/pull/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

Why was this closed?

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

Could you link to the PR? That way people that find this issue first can track it (like me :)

On Jan 11, 2017, at 7:09 PM, Jagger Wang notifications@github.com wrote:

@cava23 https://github.com/cava23 , There is already has a same issue about this, and a pull request. So I closed.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/11416#issuecomment-272064021, or mute the thread https://github.com/notifications/unsubscribe-auth/AAE48zbhTGLnhUgMHopqhisP2hmgwKoKks5rRZlbgaJpZM4LKWVV.

Duplicated as issue #7564

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-_./";
...

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?

Also hitting this issue as a regression since previous releases.

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-_./";

    ...
}

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.

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.

Was this page helpful?
0 / 5 - 0 ratings