writeMedia: unescape percent-encoding in creating file path.
Closes #7819 (problem with spaces in image filenames when creating PDFs).
This commit is contained in:
parent
2b51f54e19
commit
a6741bd555
1 changed files with 3 additions and 1 deletions
|
@ -214,13 +214,15 @@ extractMedia dir d = do
|
||||||
return $ walk (adjustImagePath dir media) d
|
return $ walk (adjustImagePath dir media) d
|
||||||
|
|
||||||
-- | Write the contents of a media bag to a path.
|
-- | Write the contents of a media bag to a path.
|
||||||
|
-- If the path contains URI escape sequences (percent-encoding),
|
||||||
|
-- these are resolved.
|
||||||
writeMedia :: (PandocMonad m, MonadIO m)
|
writeMedia :: (PandocMonad m, MonadIO m)
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-> (FilePath, MimeType, BL.ByteString)
|
-> (FilePath, MimeType, BL.ByteString)
|
||||||
-> m ()
|
-> m ()
|
||||||
writeMedia dir (fp, _mt, bs) = do
|
writeMedia dir (fp, _mt, bs) = do
|
||||||
-- we normalize to get proper path separators for the platform
|
-- we normalize to get proper path separators for the platform
|
||||||
let fullpath = normalise $ dir </> fp
|
let fullpath = normalise $ dir </> unEscapeString fp
|
||||||
liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)
|
liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)
|
||||||
logIOError $ BL.writeFile fullpath bs
|
logIOError $ BL.writeFile fullpath bs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue