From ee053a0534a2e079a3872d26282990849e69ad92 Mon Sep 17 00:00:00 2001 From: Nishant Bhasin Date: Tue, 16 Jan 2024 17:00:32 -0500 Subject: [PATCH] Refactor FXIOS-7772 [v123] Added url check for server side redirection --- .../Blockzilla/Modules/WebView/WebViewController.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/focus-ios/Blockzilla/Modules/WebView/WebViewController.swift b/focus-ios/Blockzilla/Modules/WebView/WebViewController.swift index 36378d9f30..29f29a38d7 100644 --- a/focus-ios/Blockzilla/Modules/WebView/WebViewController.swift +++ b/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()