Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #5795 #5796

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions Client/Frontend/InternalSchemeHandler/ErrorPageHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ class ErrorPageHelper {
return
}

var queryItems = [
URLQueryItem(name: InternalURL.Param.url.rawValue, value: url.absoluteString),
URLQueryItem(name: "code", value: String(error.code)),
URLQueryItem(name: "domain", value: error.domain),
URLQueryItem(name: "description", value: error.localizedDescription),
// 'timestamp' is used for the js reload logic
URLQueryItem(name: "timestamp", value: "\(Int(Date().timeIntervalSince1970 * 1000))")
]

// When an error page is reloaded, the js on the page checks if >2s have passed since the error page was initially loaded, and if so, it reloads the original url for the page. If that original page immediately errors out again, we don't want to push another error page on history stack. This will detect this case, and clear the timestamp to ensure the error page doesn't try to reload.
if let internalUrl = InternalURL(webViewUrl), internalUrl.originalURLFromErrorPage == url {
webView.evaluateJavaScript("""
Expand All @@ -264,18 +273,15 @@ class ErrorPageHelper {
location.replace(url.toString());
})();
""")

components.queryItems = queryItems
if let urlWithQuery = components.url {
webView.load(PrivilegedRequest(url: urlWithQuery) as URLRequest)
}

return
}

var queryItems = [
URLQueryItem(name: InternalURL.Param.url.rawValue, value: url.absoluteString),
URLQueryItem(name: "code", value: String(error.code)),
URLQueryItem(name: "domain", value: error.domain),
URLQueryItem(name: "description", value: error.localizedDescription),
// 'timestamp' is used for the js reload logic
URLQueryItem(name: "timestamp", value: "\(Int(Date().timeIntervalSince1970 * 1000))")
]

// If this is an invalid certificate, show a certificate error allowing the
// user to go back or continue. The certificate itself is encoded and added as
// a query parameter to the error page URL; we then read the certificate from
Expand Down