Compare commits

...

2 Commits

Author SHA1 Message Date
Christoph Hagen
1b6441e03e Fix crash for relative links 2023-02-22 11:47:26 +01:00
Christoph Hagen
5f5c250272 Add special character encoding to external links 2023-02-22 11:46:50 +01:00
2 changed files with 5 additions and 2 deletions

View File

@ -431,7 +431,7 @@ extension Element {
// Find the common elements of the path, which can be discarded // Find the common elements of the path, which can be discarded
var index = 0 var index = 0
while pageParts[index] == ownParts[index] { while index < pageParts.count && index < ownParts.count && pageParts[index] == ownParts[index] {
index += 1 index += 1
} }
// The relative path needs to go down to the first common folder, // The relative path needs to go down to the first common folder,

View File

@ -278,7 +278,10 @@ struct PageContentGenerator {
results.warning("Invalid external link definition", source: page.path) results.warning("Invalid external link definition", source: page.path)
return nil 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 let title = parts[1].trimmed
return (url, title) return (url, title)