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

Fix #8664: Add content blocker to upgrade passive mixed content #8680

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
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
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"
}
}
]