mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
[ios] Fix opening websites with percent encoding characters
Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
committed by
Yannik Bloscheck
parent
e0c579634b
commit
29d60c9af0
@@ -180,6 +180,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)openUrl:(NSString *)urlString externally:(BOOL)externally skipEncoding:(BOOL)skipEncoding
|
- (BOOL)openUrl:(NSString *)urlString externally:(BOOL)externally skipEncoding:(BOOL)skipEncoding
|
||||||
|
{
|
||||||
|
NSString * encoded;
|
||||||
|
if (skipEncoding) {
|
||||||
|
encoded = urlString;
|
||||||
|
} else if (![urlString canBeConvertedToEncoding:NSASCIIStringEncoding])
|
||||||
{
|
{
|
||||||
// TODO: This is a temporary workaround to open cyrillic/non-ASCII URLs.
|
// TODO: This is a temporary workaround to open cyrillic/non-ASCII URLs.
|
||||||
// URLs in OSM are stored in UTF-8. NSURL constructor documentation says:
|
// URLs in OSM are stored in UTF-8. NSURL constructor documentation says:
|
||||||
@@ -188,10 +193,6 @@
|
|||||||
// 1. Split the (non-ASCII) string into components (host, path, query, fragment, etc.)
|
// 1. Split the (non-ASCII) string into components (host, path, query, fragment, etc.)
|
||||||
// 2. Encode each component separately (they have different allowed characters).
|
// 2. Encode each component separately (they have different allowed characters).
|
||||||
// 3. Merge them back into the string and create NSURL.
|
// 3. Merge them back into the string and create NSURL.
|
||||||
NSString * encoded;
|
|
||||||
if (skipEncoding) {
|
|
||||||
encoded = urlString;
|
|
||||||
} else {
|
|
||||||
NSMutableCharacterSet * charset = [[NSMutableCharacterSet alloc] init];
|
NSMutableCharacterSet * charset = [[NSMutableCharacterSet alloc] init];
|
||||||
[charset formUnionWithCharacterSet:NSCharacterSet.URLHostAllowedCharacterSet];
|
[charset formUnionWithCharacterSet:NSCharacterSet.URLHostAllowedCharacterSet];
|
||||||
[charset formUnionWithCharacterSet:NSCharacterSet.URLPathAllowedCharacterSet];
|
[charset formUnionWithCharacterSet:NSCharacterSet.URLPathAllowedCharacterSet];
|
||||||
|
|||||||
Reference in New Issue
Block a user