ionic-team / ionic-team/capacitor
[Bug]: iOS not sending url encoded data if it's a number
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 1.3k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 10
Description
### Capacitor Version
Latest Dependencies:
@capacitor/cli: 7.4.2
@capacitor/core: 7.4.2
@capacitor/android: 7.4.2
@capacitor/ios: 7.4.2
Installed Dependencies:
@capacitor/android: not installed
@capacitor/ios: 7.4.2
@capacitor/core: 7.4.2
@capacitor/cli: 7.4.2
### Other API Details
```Shell
nickredding@MacBookPro BagCaddy % npm --version
11.4.2
nickredding@MacBookPro BagCaddy % node --version
v22.14.0
nickredding@MacBookPro BagCaddy % pod --version
1.14.3
```
### Platforms Affected
- [x] iOS
- [ ] Android
- [ ] Web
### Current Behavior
As of 7.4.2 iOS getRequestDataAsFormUrlEncoded behaves differently in a breaking way.
Prior to 7.4.2 this function was not encoding values. Now it is. While this is now the correct behaviour, it breaks any app code that assumes the values need to be encoded by the app, since now the values end up double-encoded and actually show up at the server not as properly decoded values but actually encoded (encoding twice then decoding once yields a once-encoded value).
An equally significant breaking change is that prior to 7.4.2 a numeric value was converted to a string as in
components.queryItems?.append(URLQueryItem(name: key, value: "\(obj[key] ?? "")"))
where is obj[key] is numeric it is converted to a string.
Now, the statement
let value = obj[key] as? String ?? ""
replaces a numeric with an empty string. Big difference!!
### Expected Behavior
I believe these fixes should have retained backward-compatibility with the previous code, as in (1) check if already encoded and don't double-encode and (b) continue to convert numbers to strings.
### Project Reproduction
https://github.com/nickredding/bug8076
### Additional Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.