git.iko.soy/typeable/pandoc
on master help sign in
T.P.Class.IO: normalise path in writeMedia.
b6c0438John MacFarlane
src/Text/Pandoc/Class/IO.hs+2−3
@@ -211,13 +211,12 @@ writeMedia :: (PandocMonad m, MonadIO m)
211 => FilePath -> MediaBag -> FilePath
211 => FilePath -> MediaBag -> FilePath
212 -> m ()
212 -> m ()
213writeMedia dir mediabag subpath = do
213writeMedia 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 /
216 let mbcontents = lookupMedia subpath mediabag
214 let mbcontents = lookupMedia subpath mediabag
217 case mbcontents of
215 case mbcontents of
218 Nothing -> throwError $ PandocResourceNotFound $ pack subpath
216 Nothing -> throwError $ PandocResourceNotFound $ pack subpath
219 Just item -> do
217 Just item -> do
218+ -- we normalize to get proper path separators for the platform
220− let fullpath = dir </> mediaPath item
219+ let fullpath = dir </> normalise (mediaPath item)
221 liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)
220 liftIOError (createDirectoryIfMissing True) (takeDirectory fullpath)
222 logIOError $ BL.writeFile fullpath $ mediaContents item
221 logIOError $ BL.writeFile fullpath $ mediaContents item
223
222