@capacitor/ios 7.6.1 → 7.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,7 +66,7 @@ open class CapacitorUrlRequest: NSObject, URLSessionTaskDelegate {
66
66
 
67
67
  var data = Data()
68
68
  var boundary = UUID().uuidString
69
- if contentType.contains("="), let contentBoundary = contentType.components(separatedBy: "=").last {
69
+ if contentType.contains("boundary="), let contentBoundary = extractBoundary(from: contentType) {
70
70
  boundary = contentBoundary
71
71
  } else {
72
72
  overrideContentType(boundary)
@@ -87,6 +87,27 @@ open class CapacitorUrlRequest: NSObject, URLSessionTaskDelegate {
87
87
  headers["Content-Type"] = contentType
88
88
  }
89
89
 
90
+ /**
91
+ Extracts the boundary value of the `content-type` header for multiplart/form-data requests, if provided
92
+ The boundary value might be surrounded by double quotes (") which will be stripped away.
93
+ */
94
+ private func extractBoundary(from contentType: String) -> String? {
95
+ if let boundaryRange = contentType.range(of: "boundary=") {
96
+ var boundary = contentType[boundaryRange.upperBound...]
97
+ if let endRange = boundary.range(of: ";") {
98
+ boundary = boundary[..<endRange.lowerBound]
99
+ }
100
+
101
+ if boundary.hasPrefix("\"") && boundary.hasSuffix("\"") {
102
+ return String(boundary.dropFirst().dropLast())
103
+ } else {
104
+ return String(boundary)
105
+ }
106
+ }
107
+
108
+ return nil
109
+ }
110
+
90
111
  public func getRequestDataAsString(_ data: JSValue) throws -> Data {
91
112
  guard let stringData = data as? String else {
92
113
  throw CapacitorUrlRequestError.serializationError("[ data ] argument could not be parsed as string")
@@ -110,7 +131,7 @@ open class CapacitorUrlRequest: NSObject, URLSessionTaskDelegate {
110
131
  }
111
132
  var data = Data()
112
133
  var boundary = UUID().uuidString
113
- if contentType.contains("="), let contentBoundary = contentType.components(separatedBy: "=").last {
134
+ if contentType.contains("boundary="), let contentBoundary = extractBoundary(from: contentType) {
114
135
  boundary = contentBoundary
115
136
  } else {
116
137
  overrideContentType(boundary)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/ios",
3
- "version": "7.6.1",
3
+ "version": "7.6.3",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",