-
Notifications
You must be signed in to change notification settings - Fork 873
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
Add HTTPS upgrade checks #23029
Merged
Merged
Add HTTPS upgrade checks #23029
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
ios/brave-ios/Sources/Brave/Assets/Interstitial Pages/Pages/HTTPBlocked.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<!-- Copyright 2024 The Brave Authors. All rights reserved. | ||
-- This Source Code Form is subject to the terms of the Mozilla Public | ||
-- License, v. 2.0. If a copy of the MPL was not distributed with this | ||
-- file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
--> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta name='viewport' content='initial-scale=1, maximum-scale=1, viewport-fit=cover'> | ||
<meta name="referrer" content="no-referrer"> | ||
<title>%page_title%</title> | ||
<link rel="stylesheet" href="internal://local/interstitial-style/BlockedDomain.css"> | ||
</head> | ||
|
||
<body dir="&locale.dir;" class="background content"> | ||
<div class="container post"> | ||
<img src="internal://local/interstitial-icon/warning-triangle-outline.svg" alt="Icon" class="icon"> | ||
</img> | ||
<h1>%blocked_title%</h1> | ||
<p class="description"> | ||
%blocked_description% | ||
<a href="https://support.brave.com/hc/en-us/articles/15513090104717-Strict-HTTPS-Upgrade-Mode-in-Brave-Browser" target="_blank" rel="noopener"> | ||
%learn_more% | ||
</a> | ||
</p> | ||
<div class="actions"> | ||
<button id="proceed-action" class="main-action">%proceed_action%</button> | ||
<button id="go-back-action" class="secondary-action">%go_back_action%</button> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
(() => { | ||
const sendAction = (action) => { | ||
webkit.messageHandlers["%message_handler%"].postMessage({ | ||
"securityToken": "%security_token%", | ||
"action": action | ||
}) | ||
} | ||
|
||
document.getElementById('proceed-action').onclick = () => { | ||
sendAction('didProceed') | ||
} | ||
|
||
document.getElementById('go-back-action').onclick = () => { | ||
sendAction('didGoBack') | ||
} | ||
})() | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
ios/brave-ios/Sources/Brave/Frontend/Browser/Handlers/HTTPBlockedHandler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import BraveShared | ||
import BraveShields | ||
import Foundation | ||
import Shared | ||
import WebKit | ||
|
||
public class HTTPBlockedHandler: InternalSchemeResponse { | ||
public static let path = InternalURL.Path.httpBlocked.rawValue | ||
|
||
public init() {} | ||
|
||
public func response(forRequest request: URLRequest) -> (URLResponse, Data)? { | ||
guard let url = request.url, let internalURL = InternalURL(url), | ||
let originalURL = internalURL.extractedUrlParam | ||
else { return nil } | ||
let response = InternalSchemeHandler.response(forUrl: internalURL.url) | ||
|
||
guard let asset = Bundle.module.path(forResource: "HTTPBlocked", ofType: "html") else { | ||
assert(false) | ||
return nil | ||
} | ||
|
||
var html = try? String(contentsOfFile: asset) | ||
.replacingOccurrences( | ||
of: "%page_title%", | ||
with: Strings.Shields.siteIsNotSecure | ||
) | ||
.replacingOccurrences( | ||
of: "%blocked_title%", | ||
with: String.localizedStringWithFormat( | ||
Strings.Shields.theConnectionIsNotSecure, | ||
"<tt>\(originalURL.domainURL.absoluteDisplayString)</tt>" | ||
) | ||
) | ||
.replacingOccurrences( | ||
of: "%blocked_description%", | ||
with: Strings.Shields.httpBlockedDescription | ||
) | ||
.replacingOccurrences( | ||
of: "%learn_more%", | ||
with: Strings.learnMore | ||
) | ||
.replacingOccurrences( | ||
of: "%proceed_action%", | ||
with: Strings.Shields.domainBlockedProceedAction | ||
) | ||
.replacingOccurrences(of: "%go_back_action%", with: Strings.Shields.domainBlockedGoBackAction) | ||
.replacingOccurrences( | ||
of: "%message_handler%", | ||
with: HTTPBlockedScriptHandler.messageHandlerName | ||
) | ||
.replacingOccurrences(of: "%security_token%", with: UserScriptManager.securityToken) | ||
|
||
if #available(iOS 16.0, *) { | ||
html = html?.replacingOccurrences( | ||
of: "<html lang=\"en\">", | ||
with: "<html lang=\"\(Locale.current.language.minimalIdentifier)\">" | ||
) | ||
} | ||
|
||
guard let data = html?.data(using: .utf8) else { | ||
return nil | ||
} | ||
|
||
return (response, data) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about this >= 400 check? What happens if the response is a 000?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so:
brave-core/chromium_src/chrome/browser/ssl/https_upgrades_interceptor.cc
Line 44 in c4daecc