Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #8664: Add content blocker to upgrade passive mixed content (#8680)
Browse files Browse the repository at this point in the history
Also hides the 'Not Secure' title when viewing mixed content

Due to a WebKit bug we will still be showing the page as insecure even when all http links are promoted, so this will help with that until the bug is fixed by Apple
  • Loading branch information
kylehickinson committed Jan 23, 2024
1 parent f08b741 commit 98e7802
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ var braveTarget: PackageDescription.Target = .target(
.copy("WebFilters/ContentBlocker/Lists/block-ads.json"),
.copy("WebFilters/ContentBlocker/Lists/block-cookies.json"),
.copy("WebFilters/ContentBlocker/Lists/block-trackers.json"),
.copy("WebFilters/ContentBlocker/Lists/mixed-content-upgrade.json"),
.copy("WebFilters/ShieldStats/Adblock/Resources/ABPFilterParserData.dat"),
],
plugins: ["LoggerPlugin"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ class TabLocationView: UIView {
var title = AttributedString(Strings.tabToolbarNotSecureTitle)
title.font = .preferredFont(forTextStyle: .subheadline, compatibleWith: clampedTraitCollection)

let isTitleVisible = !traitCollection.preferredContentSizeCategory.isAccessibilityCategory && bounds.width > 200
// Hide the title with mixed content due to a WebKit bug (https://bugs.webkit.org/show_bug.cgi?id=258711)
// which fails to update `hasOnlySecureContent` even when promoting all http content.
let isTitleVisible = !traitCollection.preferredContentSizeCategory.isAccessibilityCategory &&
bounds.width > 200 && secureContentState != .mixedContent

switch secureContentState {
case .localhost, .secure:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ actor ContentBlockerManager {
case blockAds
case blockCookies
case blockTrackers
case upgradeMixedContent

func mode(isAggressiveMode: Bool) -> BlockingMode {
switch self {
Expand All @@ -60,7 +61,7 @@ actor ContentBlockerManager {
} else {
return .standard
}
case .blockCookies, .blockTrackers:
case .blockCookies, .blockTrackers, .upgradeMixedContent:
return .general
}
}
Expand All @@ -70,6 +71,7 @@ actor ContentBlockerManager {
case .blockAds: return "block-ads"
case .blockCookies: return "block-cookies"
case .blockTrackers: return "block-trackers"
case .upgradeMixedContent: return "mixed-content-upgrade"
}
}
}
Expand Down Expand Up @@ -356,6 +358,9 @@ actor ContentBlockerManager {
results.insert(.blockCookies)
}

// Always upgrade mixed content
results.insert(.upgradeMixedContent)

return results
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"trigger": {
"url-filter": "http://.*",
"if-top-url": ["https://.*"],
"resource-type": ["image", "media"]
},
"action": {
"type": "make-https"
}
}
]

0 comments on commit 98e7802

Please sign in to comment.