git.iko.soy/typeable/pandoc
on master help sign in
T.P.Class.IO: normalise path in writeMedia.

This ensures that we get `\` separators on Windows.

commitb6c04383e403b0962db09e6748760d3ec376f2ed authorJohn MacFarlane <jgm@berkeley.edu> dateThu 3 Jun 2021, 18:34 (5 years ago) parenta54a19c
1 file changed+2−3
src/Text/Pandoc/Class/IO.hs+2−3
src/Text/Pandoc/Class/IO.hs+2−3
@@ -211,13 +211,12 @@ writeMedia :: (PandocMonad m, MonadIO m)
211211 => FilePath -> MediaBag -> FilePath
212212 -> m ()
213213writeMedia dir mediabag subpath = do
214− -- we join and split to convert a/b/c to a\b\c on Windows;
215− -- in zip containers all paths use /
216214 let mbcontents = lookupMedia subpath mediabag
217215 case mbcontents of
218216 Nothing -> throwError $ PandocResourceNotFound $ pack subpath
219217 Just item -> do
220− let fullpath = dir </> mediaPath item
218+ -- we normalize to get proper path separators for the platform
219+ let fullpath = dir </> normalise (mediaPath item)
221220 liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)
222221 logIOError $ BL.writeFile fullpath $ mediaContents item
223222