From 60640b235e42bb7fd1e718dedc4c799d24a95cfc Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Thu, 29 Oct 2026 12:30:00 -0700 Subject: [PATCH] Use timeline copy in iOS image viewer only if correctly signed. --- iOS/Article/WebViewController.swift | 8 ++++---- iOS/Resources/main_ios.js | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index a521f5025..dba64fac2 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -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 ’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 } diff --git a/iOS/Resources/main_ios.js b/iOS/Resources/main_ios.js index 4f5e942ed..3d262197e 100644 --- a/iOS/Resources/main_ios.js +++ b/iOS/Resources/main_ios.js @@ -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);