Skip to content

Commit

Permalink
fix(ios): remove new line character in multipart/form-data requests
Browse files Browse the repository at this point in the history
Removes new line characters `\r\n` which are incorrectly appended to the
data of multipart/form-data requests. This change removes these new line
characters in order to comply with the specifications, as defined here:
https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2

Fixes: ionic-team#6748
  • Loading branch information
michaelwolz committed Feb 12, 2024
1 parent a989c4d commit d4c9cb1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions ios/Capacitor/Capacitor/Plugins/CapacitorUrlRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,12 @@ open class CapacitorUrlRequest: NSObject, URLSessionTaskDelegate {
data.append("\r\n".data(using: .utf8)!)

data.append(Data(base64Encoded: value)!)

data.append("\r\n".data(using: .utf8)!)
} else if type == "string" {
data.append("\r\n--\(boundary)\r\n".data(using: .utf8)!)
data.append("Content-Disposition: form-data; name=\"\(key!)\"\r\n".data(using: .utf8)!)
data.append("\r\n".data(using: .utf8)!)

data.append(value.data(using: .utf8)!)
data.append("\r\n".data(using: .utf8)!)
}

}
Expand Down

0 comments on commit d4c9cb1

Please sign in to comment.