From 028c556a50b41ee99fe8f4f1aa2f42d3fd57f92d Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Thu, 26 Jan 2023 18:08:09 +0100 Subject: [PATCH] fix(ios): crash when http headers contain numbers (#6251) --- android/capacitor/src/main/assets/native-bridge.js | 8 +++++--- core/native-bridge.ts | 6 ++++-- ios/Capacitor/Capacitor/assets/native-bridge.js | 8 +++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/android/capacitor/src/main/assets/native-bridge.js b/android/capacitor/src/main/assets/native-bridge.js index 5a3abdc2b9..e73f78f231 100644 --- a/android/capacitor/src/main/assets/native-bridge.js +++ b/android/capacitor/src/main/assets/native-bridge.js @@ -2,7 +2,7 @@ /*! Capacitor: https://capacitorjs.com/ - MIT License */ /* Generated File. Do not edit. */ -const nativeBridge = (function (exports) { +var nativeBridge = (function (exports) { 'use strict'; var ExceptionCode; @@ -376,7 +376,9 @@ const nativeBridge = (function (exports) { url: resource, method: (options === null || options === void 0 ? void 0 : options.method) ? options.method : undefined, data: (options === null || options === void 0 ? void 0 : options.body) ? options.body : undefined, - headers: (options === null || options === void 0 ? void 0 : options.headers) ? options.headers : undefined, + headers: (options === null || options === void 0 ? void 0 : options.headers) + ? JSON.stringify(options.headers) + : undefined, }); const data = typeof nativeResponse.data === 'string' ? nativeResponse.data @@ -500,7 +502,7 @@ const nativeBridge = (function (exports) { url: this._url, method: this._method, data: body !== null ? body : undefined, - headers: this._headers, + headers: JSON.stringify(this._headers), }) .then((nativeResponse) => { // intercept & parse response before returning diff --git a/core/native-bridge.ts b/core/native-bridge.ts index 31d6827d71..f356ba0fb7 100644 --- a/core/native-bridge.ts +++ b/core/native-bridge.ts @@ -427,7 +427,9 @@ const initBridge = (w: any): void => { url: resource, method: options?.method ? options.method : undefined, data: options?.body ? options.body : undefined, - headers: options?.headers ? options.headers : undefined, + headers: options?.headers + ? JSON.stringify(options.headers) + : undefined, }, ); @@ -583,7 +585,7 @@ const initBridge = (w: any): void => { url: this._url, method: this._method, data: body !== null ? body : undefined, - headers: this._headers, + headers: JSON.stringify(this._headers), }) .then((nativeResponse: any) => { // intercept & parse response before returning diff --git a/ios/Capacitor/Capacitor/assets/native-bridge.js b/ios/Capacitor/Capacitor/assets/native-bridge.js index 5a3abdc2b9..e73f78f231 100644 --- a/ios/Capacitor/Capacitor/assets/native-bridge.js +++ b/ios/Capacitor/Capacitor/assets/native-bridge.js @@ -2,7 +2,7 @@ /*! Capacitor: https://capacitorjs.com/ - MIT License */ /* Generated File. Do not edit. */ -const nativeBridge = (function (exports) { +var nativeBridge = (function (exports) { 'use strict'; var ExceptionCode; @@ -376,7 +376,9 @@ const nativeBridge = (function (exports) { url: resource, method: (options === null || options === void 0 ? void 0 : options.method) ? options.method : undefined, data: (options === null || options === void 0 ? void 0 : options.body) ? options.body : undefined, - headers: (options === null || options === void 0 ? void 0 : options.headers) ? options.headers : undefined, + headers: (options === null || options === void 0 ? void 0 : options.headers) + ? JSON.stringify(options.headers) + : undefined, }); const data = typeof nativeResponse.data === 'string' ? nativeResponse.data @@ -500,7 +502,7 @@ const nativeBridge = (function (exports) { url: this._url, method: this._method, data: body !== null ? body : undefined, - headers: this._headers, + headers: JSON.stringify(this._headers), }) .then((nativeResponse) => { // intercept & parse response before returning