mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-03 18:56:14 +00:00
Stop rejecting photos with "track" or "open" in name since they could be legitimate.
This commit is contained in:
1 parent
f70d5e0e38
commit
8955619c40
2 files changed
+6
-1
No files matched your search
@@ -53,6 +53,9 @@ private extension SignificantImageFilter {
|
||||
/// Path components of open-tracking and click-tracking URLs on any host. Lowercase.
|
||||
static let blockedPathComponents: Set<String> = ["open", "track"]
|
||||
|
||||
/// A URL ending in one of these isn’t blocked by its path components. GIF isn’t included, since it’s the usual format for tracking pixels.
|
||||
static let photoFileExtensions: Set<String> = ["avif", "heic", "jpeg", "jpg", "png", "webp"]
|
||||
|
||||
/// Share buttons, badges, tracking pixels, and placeholders. Hosts include their subdomains. Path prefixes are lowercase.
|
||||
static let blockedImagePrefixes: [HostAndPathPrefix] = [
|
||||
(host: "addtoany.com", pathPrefix: "/"),
|
||||
@@ -105,7 +108,7 @@ private extension SignificantImageFilter {
|
||||
if blockedFileNames.contains(url.deletingPathExtension().lastPathComponent.lowercased()) {
|
||||
return true
|
||||
}
|
||||
if url.pathComponents.contains(where: { blockedPathComponents.contains($0.lowercased()) }) {
|
||||
if !photoFileExtensions.contains(url.pathExtension.lowercased()), url.pathComponents.contains(where: { blockedPathComponents.contains($0.lowercased()) }) {
|
||||
return true
|
||||
}
|
||||
if matches(host: host, path: url.path().lowercased(), blockedImagePrefixes) {
|
||||
|
||||
@@ -155,6 +155,8 @@ import RSParser
|
||||
#expect(!SignificantImageFilter.isSignificant(urlString: "https://example.com/banner.jpg", width: 1200, height: 250))
|
||||
#expect(!SignificantImageFilter.isSignificant(urlString: "https://example.com/images/spacer.gif", width: nil, height: nil))
|
||||
#expect(!SignificantImageFilter.isSignificant(urlString: "https://email.example.net/open/abc123.gif", width: nil, height: nil))
|
||||
#expect(!SignificantImageFilter.isSignificant(urlString: "https://email.example.net/wf/open?upn=abc123", width: nil, height: nil))
|
||||
#expect(SignificantImageFilter.isSignificant(urlString: "https://cdn.example.com/track/cover.jpg", width: nil, height: nil))
|
||||
#expect(SignificantImageFilter.isSignificant(urlString: "https://example.com/2026/open-source-pixel-art.jpg", width: nil, height: nil))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user