Use percent-encoding — via URLComponents — on the articleID in the nnwImageIcon URL scheme.

This commit is contained in:
Brent Simmons 2020-02-08 17:21:55 -08:00
parent f1e01e06fc
commit cac67f8ac4
2 changed files with 15 additions and 4 deletions

View File

@ -140,7 +140,16 @@ private extension ArticleRenderer {
d["title"] = title
d["body"] = body
d["avatars"] = "<td class=\"header rightAlign avatar\"><img id=\"nnwImageIcon\" src=\"\(ArticleRenderer.imageIconScheme)://\(article.articleID)\" height=48 width=48 /></td>";
var components = URLComponents()
components.scheme = Self.imageIconScheme
components.path = article.articleID
if let imageIconURLString = components.string {
d["avatars"] = "<td class=\"header rightAlign avatar\"><img id=\"nnwImageIcon\" src=\"\(imageIconURLString)\" height=48 width=48 /></td>"
}
else {
d["avatars"] = ""
}
var feedLink = ""
if let feedTitle = article.webFeed?.nameForDisplay {

View File

@ -24,9 +24,11 @@ class ArticleIconSchemeHandler: NSObject, WKURLSchemeHandler {
urlSchemeTask.didFailWithError(URLError(.fileDoesNotExist))
return
}
let articleID = url.absoluteString.stripping(prefix: "\(ArticleRenderer.imageIconScheme)://")
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else {
return
}
let articleID = components.path
guard let iconImage = coordinator.articleFor(articleID)?.iconImage() else {
urlSchemeTask.didFailWithError(URLError(.fileDoesNotExist))
return