From 9d1979527889f53a1c407e8510eceabe413ed87f Mon Sep 17 00:00:00 2001 From: Nishant Bhasin Date: Wed, 17 Jan 2024 03:35:29 -0500 Subject: [PATCH] [focus-ios] Refactor FXIOS-7772 [v123] Added url check for server side redirection (https://github.com/mozilla-mobile/focus-ios/pull/3989) --- .../Blockzilla/Modules/WebView/WebViewController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/focus-ios/focus-ios/Blockzilla/Modules/WebView/WebViewController.swift b/focus-ios/focus-ios/Blockzilla/Modules/WebView/WebViewController.swift index 36378d9f30ac..29f29a38d77a 100644 --- a/focus-ios/focus-ios/Blockzilla/Modules/WebView/WebViewController.swift +++ b/focus-ios/focus-ios/Blockzilla/Modules/WebView/WebViewController.swift @@ -379,6 +379,16 @@ extension WebViewController: UIScrollViewDelegate { } extension WebViewController: WKNavigationDelegate { + func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!) { + // validate the URL using URIFixup + guard let urlString = webView.url?.absoluteString, + URIFixup.getURL(entry: urlString) != nil else { + // URL failed validation, prevent loading + stop() + return + } + } + func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) { delegate?.webControllerDidStartNavigation(self) trackingProtectionManager.trackingProtectionStatus.trackingInformation = TPPageStats()