Skip to content
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

feat(ios): replace deprecated properties #633

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

u01jmg3
Copy link

@u01jmg3 u01jmg3 commented Aug 4, 2024

Platforms affected

iOS

Motivation and Context

#631

Description

Replace deprecated properties

Testing

Expect GitHub Actions test suite to pass as before

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@u01jmg3 u01jmg3 changed the title Replace deprecated properties feat(ios): replace deprecated properties Aug 4, 2024
@breautek
Copy link
Contributor

breautek commented Aug 4, 2024

stringByRemovingPercentEncoding and stringByAddingPercentEncodingWithAllowedCharacters are both iOS 7+ so compatibility wise it should be fine.

The newer APIs gives a warning...

stringByRemovingPercentEncoding:

You must call this method only on strings that you know to be percent-encoded. Calling this method on strings that are not percent-encoded can lead to misinterpreting a percent character as the beginning of a percent-encoded sequence.

stringByAddingPercentEncodingWithAllowedCharacters:

You must not call this method on strings that are already percent-encoded. Calling this method on strings that are already percent-encoded will cause percent characters in a percent-encoded sequence to be percent-encoded twice.

I'm not sure how the older deprecated APIs behave but the encodePath API path has comments suggesting it doesn't know if the given url is already encoded or not (by blindly decoding it and re-encoding it). Depending how the deprecated API behaves, switching out the APIs might not be sufficient.

stringByAddingPercentEncodingWithAllowedCharacters has a similar warning that encoding an already encoded url will result in double encoding.

Also stringByAddingPercentEncodingWithAllowedCharacters is being used wrong, as it doesn't accept character encoding, but a NSCharacterSet instead defining allowed characters. So that's failing the build.

@u01jmg3
Copy link
Author

u01jmg3 commented Aug 5, 2024

Thanks for the detailed review. I'll let you decide if it's worth pursuing these changes, especially as it's not a like-for-like replacement in either case. My aim was to reduce the amount of noise I was seeing in my log as deprecation warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants