From 5f5c250272035e7c79dbb2b9dcb8100f9f8f663b Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Wed, 22 Feb 2023 11:46:50 +0100 Subject: [PATCH] Add special character encoding to external links --- Sources/Generator/Generators/PageContentGenerator.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Generator/Generators/PageContentGenerator.swift b/Sources/Generator/Generators/PageContentGenerator.swift index aea5ef2..14a90ad 100644 --- a/Sources/Generator/Generators/PageContentGenerator.swift +++ b/Sources/Generator/Generators/PageContentGenerator.swift @@ -278,7 +278,10 @@ struct PageContentGenerator { results.warning("Invalid external link definition", source: page.path) return nil } - let url = parts[0].trimmed + guard let url = parts[0].trimmed.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else { + results.warning("Invalid external link \(parts[0].trimmed)", source: page.path) + return nil + } let title = parts[1].trimmed return (url, title)