From 6e717a8cf7c5aae19aa027d472fe16ab09dbda85 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Mon, 20 Feb 2023 15:40:31 +0100 Subject: [PATCH] Decode percent encodings for markdown images --- Sources/Generator/Generators/PageContentGenerator.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/Generator/Generators/PageContentGenerator.swift b/Sources/Generator/Generators/PageContentGenerator.swift index 957eaf8..aea5ef2 100644 --- a/Sources/Generator/Generators/PageContentGenerator.swift +++ b/Sources/Generator/Generators/PageContentGenerator.swift @@ -87,8 +87,11 @@ struct PageContentGenerator { // For a simple boxes: ![box](title;body) // A fancy page link: ![page](page_id) // External pages: ![external](url1, text1; url2, text2, ...) - let fileAndTitle = markdown.between(first: "](", andLast: ")") - let alt = markdown.between("[", and: "]").nonEmpty + guard let fileAndTitle = markdown.between(first: "](", andLast: ")").removingPercentEncoding else { + results.warning("Invalid percent encoding for markdown image", source: page.path) + return "" + } + let alt = markdown.between("[", and: "]").nonEmpty?.removingPercentEncoding if let alt = alt, let command = ShorthandMarkdownKey(rawValue: alt) { return handleShortHandCommand(command, page: page, language: language, content: fileAndTitle) }