-
Notifications
You must be signed in to change notification settings - Fork 997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: multipart/form-data encoding error in CapacitorUrlRequest.swift #6748
Comments
this is fixed in v5.2.x with PR #6722 |
@5uper The pull request you reference only partially fixes the issue. That PR fixes the syntax of the multipart/form-data encoding but there is still data corruption because of the additional This is the additional fix required: |
This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. |
No further time is available for this so we'll leave our fix available for anyone experiencing the same issue. To any capacitor users experiencing this problem with Capacitor v4.8.1 or v5.2.x:
Alternatively, modify the last line before "return" to remove the first "\r\n":
|
+1 for your work. We need this asap merged 👍 |
A possible solution until this issue is resolved is to create a post-install script to remove that line |
In what sense does this issue "require more information before it can be addressed"? It's pretty clear what's going on, and super easy to replicate - post a form from an iOS device. The suggested solution works (thanks @heyrex) but is modifying the package at build time really the intended way to use Capcitor? |
Any update on this? |
Any update on this? I noticed that in my case it's appending a \r\n to my values, resulting in a value containing formatting characters. I'm using version capacitor core/ios with verison 5.6.0. |
Removes new line characters `\r\n` which are incorretly 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
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
This comment was marked as off-topic.
This comment was marked as off-topic.
if you want to use the tmp solution with a
with the patch file
|
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
The recently introduced FormData support in CapacitorHttp incorrectly encodes form values on iOS (works correctly for Android).
On iOS
getRequestDataFromFormData()
incorrectly adds\r\n
below the value and omits it above. multipart/form-data encoding requires an empty line between the headers and the value. There should be no empty line after the value. It should be immediately proceeded by the boundary.The two lines referenced here should be reversed:
https://github.com/ionic-team/capacitor/blob/2e43323410bab7c3381a0f11a6fd3880bde03a70/ios/Capacitor/Capacitor/Plugins/CapacitorUrlRequest.swift#L135C1-L136C56
It also looks like an additional \r\n is being appended to any data where
type == "base64File"
.See:
capacitor/ios/Capacitor/Capacitor/Plugins/CapacitorUrlRequest.swift
Line 131 in 3cd7196
The text was updated successfully, but these errors were encountered: