mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-30 17:29:23 +00:00
Use timeline copy in iOS image viewer only if correctly signed.
This commit is contained in:
1 parent
814e7d0d89
commit
60640b235e
2 files changed
+6
-7
No files matched your search
@@ -593,8 +593,7 @@ private struct ImageClickMessage: Codable {
|
||||
let width: Float
|
||||
let height: Float
|
||||
let imageTitle: String?
|
||||
let imageURL: String
|
||||
let isTimelineImage: Bool // Served from the timeline’s copy
|
||||
let imageURL: String // The <img>’s src, which may be a routed timeline image
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
@@ -757,8 +756,9 @@ private extension WebViewController {
|
||||
imageDownloadTask?.cancel()
|
||||
imageDownloadTask = Task { [weak self] in
|
||||
var data: Data?
|
||||
if clickMessage.isTimelineImage {
|
||||
data = try? await ArticleThumbnailFinder.shared.fullSizeImageData(url: clickMessage.imageURL, articleTitle: nil)
|
||||
// Only a correctly signed routed URL uses the timeline’s copy, so page content can’t claim one.
|
||||
if imageURL.scheme?.caseInsensitiveCompare(ArticleRenderer.articleImageScheme) == .orderedSame, let timelineImageURL = ArticleImageSchemeHandler.imageURL(imageURL) {
|
||||
data = try? await ArticleThumbnailFinder.shared.fullSizeImageData(url: timelineImageURL, articleTitle: nil)
|
||||
} else {
|
||||
data = try? await Downloader.shared.download(imageURL, userAgentStyle: .browser).data
|
||||
}
|
||||
|
||||
@@ -37,15 +37,14 @@ class ImageViewer {
|
||||
const rect = this.img.getBoundingClientRect();
|
||||
|
||||
// Instead of trying to convert to canvas (which fails with CORS),
|
||||
// send the original image src URL
|
||||
// send the image's src URL. Swift checks a routed timeline image's signature.
|
||||
const message = {
|
||||
x: rect.x,
|
||||
y: rect.y,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
imageTitle: this.img.title,
|
||||
imageURL: this.img.dataset.nnwSrc || this.img.src,
|
||||
isTimelineImage: this.img.hasAttribute("data-nnw-src"),
|
||||
imageURL: this.img.src,
|
||||
};
|
||||
|
||||
var jsonMessage = JSON.stringify(message);
|
||||
|
||||
Reference in new issue
Block a user