From 8ec774396c03f136104f1e916200d1fc359cda0d Mon Sep 17 00:00:00 2001 From: unordered Date: Wed, 14 Dec 2016 08:15:37 -0800 Subject: [PATCH] fix ios formdata boundary include slash Summary: some server not work when upload a file with FromData in ios. the reason is that there is a slash in boundary, like: ``` multipart/form-data; boundary=b/QeEbFgqK9PCZo4T/eXv7f.T74SHd5MxCZ846AsTz-yNV0xrRR_Zks4fkNMCzJck9ZE8o // koa request.js (line 548) is(types) { if (!types) return typeis(this.req); if (!Array.isArray(types)) types = [].slice.call(arguments); return typeis(this.req, types); } // type-is index.js (line 237) function normalizeType (value) { // parse the type var type = typer.parse(value) // remove the parameters type.parameters = undefined // reformat it return typer.format(type) } // media-typer var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g; ``` thanks for dougwilson 's [answer](https://github.com/jshttp/media-typer/issues/5). > The / is an illegal character for Content-Type, which is what this module parses Closes https://github.com/facebook/react-native/pull/11342 Differential Revision: D4326750 Pulled By: javache fbshipit-source-id: b1c78a335c95a5c223537545d87beaffe15d673d --- Libraries/Network/RCTNetworking.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Network/RCTNetworking.mm b/Libraries/Network/RCTNetworking.mm index 70d2ede18..a8aa11a62 100644 --- a/Libraries/Network/RCTNetworking.mm +++ b/Libraries/Network/RCTNetworking.mm @@ -49,7 +49,7 @@ typedef RCTURLRequestCancellationBlock (^RCTHTTPQueryResult)(NSError *error, NSD static NSString *RCTGenerateFormBoundary() { const size_t boundaryLength = 70; - const char *boundaryChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_./"; + const char *boundaryChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_."; char *bytes = (char*)malloc(boundaryLength); size_t charCount = strlen(boundaryChars);