Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pound symbol added to URL in ios 14

I have a running app in a webserver, that redirects to an app installed on a iOS 14 device. the url is in the form of

myapp://?p=someBase64EncodedString

and the application is decoding the string. after upgrading to iOS 14, the url the app gets is

myapp://?p=someBase64EncodedString# and the pound symbol added to the end of the string fails to decode on my device. When using ignoreUnknownCharacters everything works fine, but where did this # come from?

like image 452
Nati Avatar asked Nov 05 '20 13:11

Nati


People also ask

What is URL in Swift iOS?

A value that identifies the location of a resource, such as an item on a remote server or the path to a local file. iOS 7.0+ iPadOS 7.0+ macOS 10.9+ Mac Catalyst 13.0+ tvOS 9.0+ watchOS 2.0+ Xcode 8.0+

Is the pound sign?

The symbol £, representing the pound sterling. (US) The symbol #, denoting weight in pounds. A bag of peanuts is marked "5#".

How to use pound sign or hash mark in click-through url?

Use pound sign or hash mark in click-through. There are several ways to use a hash mark or pound sign (#) in a click-through URL. But first, some background. In a URL, a hash mark, number sign, or pound sign (#) points a browser to a specific spot in a page or website. It is used to separate the URI of an object from a fragment identifier.

What is URL scheme in iOS?

Working with URL Schemes in iOS Apps. The URL scheme is an interesting feature provided by the iOS SDK that allows developers to launch system apps and third-party apps through URLs. For example, let’s say your app displays a phone number, and you want to make a call whenever a user taps that number.

How do I get the pound (sterling) symbol on my keyboard?

On a US keyboard, the pound (sterling) symbol is accessed using Option-3 instead of Shift-3. If Option-3 yields that symbol on your keyboard now, I suspect something has gone amiss with your keyboard selection or a related preference file — but I don't know OS X well enough to tell you where to look for the trouble.

What's new in iOS 14 and the Shortcuts app?

Perhaps the most popular addition to iOS 14 and the Shortcuts app is the ability to create custom app icons. Combine custom app icons with widgets anywhere, and you can create a unique home screen that looks stunning. The process is a little tedious, but if you're willing to put in the work, you can have a totally custom look.


2 Answers

As @jtbandes mentioned in the comments, # is valid character in a URL.

To avoid this kind of issues, the safest way to parse a URL is by using URLComponents, following this answer.

Here is an example:

let urlString = "https://test.host.com:8080/Test/Path?test_parameter=test_value#test-fragment"
let urlComponents = URLComponents(string: urlString)

print("scheme: \(urlComponents?.scheme ?? "nil")")
print("host: \(urlComponents?.host ?? "nil")")
print("port: \(urlComponents?.port ?? -1)")
print("path: \(urlComponents?.path ?? "nil")")
print("query: \(urlComponents?.query ?? "nil")")
print("queryItems: \(urlComponents?.queryItems ?? [])")
print("fragment: \(urlComponents?.fragment ?? "nil")")

This will have as output:

scheme: https
host: test.host.com
port: 8080
path: /Test/Path
query: test_parameter=test_value
queryItems: [test_parameter=test_value]
fragment: test-fragment
like image 70
gcharita Avatar answered Oct 23 '22 23:10

gcharita


Could Swift 5 and raw strings be the culprit? My guess is that the application is using # as a custom string delimiter and on the decoding is replacing some special character with an #.

like image 21
Dan M Avatar answered Oct 24 '22 00:10

Dan M