From 16df826d1dfa0181ed5bfb01ce3aa7c5b40a0b94 Mon Sep 17 00:00:00 2001 From: OrlaM Date: Wed, 13 Dec 2023 13:37:16 -0500 Subject: [PATCH] Fix url encoding (#3949) (cherry picked from commit c43e34ebdb5df3469aef3397b4beb01884c7de64) --- Blockzilla/Utilities/URIFixup.swift | 2 +- focus-ios/ClientTests/URIFixupTests.swift | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Blockzilla/Utilities/URIFixup.swift b/Blockzilla/Utilities/URIFixup.swift index 35381d1ba9..2ed6695982 100644 --- a/Blockzilla/Utilities/URIFixup.swift +++ b/Blockzilla/Utilities/URIFixup.swift @@ -7,7 +7,7 @@ import Foundation class URIFixup { static func getURL(entry: String) -> URL? { let trimmed = entry.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) - guard let escaped = trimmed.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics) else { + guard let escaped = trimmed.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlAllowed) else { return nil } diff --git a/focus-ios/ClientTests/URIFixupTests.swift b/focus-ios/ClientTests/URIFixupTests.swift index cae2d33b6c..d31c8e7938 100644 --- a/focus-ios/ClientTests/URIFixupTests.swift +++ b/focus-ios/ClientTests/URIFixupTests.swift @@ -48,7 +48,6 @@ class URIFixupTests: XCTestCase { "http://moz.fir/?q=Test%20URL-encoded%20fire", "http://مثال.إختبار", "http://王涵.王涵", - "http://-.~_!$&'()*+,;=:%40:80%2f::::::@mozilla.org", "http://6662.net", "http://f.i-r.ef", "http://266.315.245.345", @@ -74,13 +73,6 @@ class URIFixupTests: XCTestCase { } } - func testValidURLsForNoSchemes() { - httpSchemeURLs.forEach { - let noSchemeURL = $0.replacingOccurrences(of: "http", with: "") - XCTAssertNotNil(URIFixup.getURL(entry: noSchemeURL), "\(noSchemeURL) is not a valid URL") - } - } - func testCustomSchemes() { customSchemeURLs.forEach { XCTAssertNotNil(URIFixup.getURL(entry: $0), "\($0) is not a valid URL")