git.iko.soy/typeable/pandoc
on master help sign in
EPUB reader: Fixed bug where filepaths weren't sufficiently normalised
commit9eded27e32f7f609a1c501a285f93119cdf20b9f authorMatthew Pickering <matthewtpickering@gmail.com> dateMon 11 Aug 2014, 11:20 (12 years ago) parent1f02ff6
1 file changed+5−4
src/Text/Pandoc/Readers/EPUB.hs+5−4
src/Text/Pandoc/Readers/EPUB.hs+5−4
@@ -169,10 +169,10 @@ getManifest archive = do
169169 ns <- mkE "xmlns not in namespaces" (lookup "xmlns" namespaces)
170170 as <- liftM ((map attrToPair) . elAttribs)
171171 (findElementE (QName "rootfile" (Just ns) Nothing) docElem)
172− root <- mkE "Root not found" (lookup "full-path" as)
173− let rootdir = dropFileName root
172+ manifestFile <- mkE "Root not found" (lookup "full-path" as)
173+ let rootdir = dropFileName manifestFile
174174 --mime <- lookup "media-type" as
175− manifest <- findEntryByPathE root archive
175+ manifest <- findEntryByPathE manifestFile archive
176176 liftM ((,) rootdir) (parseXMLDocE . UTF8.toStringLazy . fromEntry $ manifest)
177177
178178-- Fixup
@@ -272,7 +272,8 @@ findAttrE :: MonadError String m => QName -> Element -> m String
272272findAttrE q e = mkE "findAttr" $ findAttr q e
273273
274274findEntryByPathE :: MonadError String m => FilePath -> Archive -> m Entry
275−findEntryByPathE path a = mkE ("No entry on path: " ++ path) $ findEntryByPath path a
275+findEntryByPathE (normalise -> path) a =
276+ mkE ("No entry on path: " ++ path) $ findEntryByPath path a
276277
277278parseXMLDocE :: MonadError String m => String -> m Element
278279parseXMLDocE doc = mkE "Unable to parse XML doc" $ parseXMLDoc doc