Skip to content

[Bug]: iOS not sending url encoded data if it's a number  #8076

@nickredding

Description

@nickredding

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

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

  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions