Skip to content

Commit 46945c9

Browse files
committed
url decode paths before using them to form names
Fixes #5089 (this is allowing slashes and other character that are url encoded to slip by our safe naming)
1 parent fac5739 commit 46945c9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/resources/filters/quarto-post/pdf-images.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ function pdfImages()
109109
else
110110
local relativePath = image.src:match('https?://[%w%.%:]+/(.+)')
111111
if relativePath then
112+
112113
local imgMt, imgContents = pandoc.mediabag.fetch(image.src)
113-
local filename = windows_safe_filename(tex_safe_filename(pandoc.path.filename(relativePath)))
114+
local decodedSrc = urldecode(image.src)
115+
if decodedSrc == nil then
116+
decodedSrc = "unknown"
117+
end
118+
local filename = windows_safe_filename(tex_safe_filename(pandoc.path.filename(decodedSrc)))
114119
if imgMt ~= nil then
115120
local existingMt = pandoc.mediabag.lookup(filename)
116121
local counter = 1
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Simple Document
3+
format: pdf
4+
---
5+
6+
## Url with encoding
7+
8+
![](https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9b7345d9-5f62-46dc-8062-d704c2c014a5_289x174.jpeg)
9+
10+
11+
## Simple Url
12+
13+
![](https://quarto.org/quarto.png)

0 commit comments

Comments
 (0)