git.iko.soy/typeable/pandoc
on master help sign in
EPUB reader: Fixed bug where filepaths weren't sufficiently normalised
9eded27Matthew Pickering
src/Text/Pandoc/Readers/EPUB.hs+5−4
@@ -169,10 +169,10 @@ getManifest archive = do
169 ns <- mkE "xmlns not in namespaces" (lookup "xmlns" namespaces)
169 ns <- mkE "xmlns not in namespaces" (lookup "xmlns" namespaces)
170 as <- liftM ((map attrToPair) . elAttribs)
170 as <- liftM ((map attrToPair) . elAttribs)
171 (findElementE (QName "rootfile" (Just ns) Nothing) docElem)
171 (findElementE (QName "rootfile" (Just ns) Nothing) docElem)
172− root <- mkE "Root not found" (lookup "full-path" as)
172+ manifestFile <- mkE "Root not found" (lookup "full-path" as)
173− let rootdir = dropFileName root
173+ let rootdir = dropFileName manifestFile
174 --mime <- lookup "media-type" as
174 --mime <- lookup "media-type" as
175− manifest <- findEntryByPathE root archive
175+ manifest <- findEntryByPathE manifestFile archive
176 liftM ((,) rootdir) (parseXMLDocE . UTF8.toStringLazy . fromEntry $ manifest)
176 liftM ((,) rootdir) (parseXMLDocE . UTF8.toStringLazy . fromEntry $ manifest)
177
177
178-- Fixup
178-- Fixup
@@ -272,7 +272,8 @@ findAttrE :: MonadError String m => QName -> Element -> m String
272findAttrE q e = mkE "findAttr" $ findAttr q e
272findAttrE q e = mkE "findAttr" $ findAttr q e
273
273
274findEntryByPathE :: MonadError String m => FilePath -> Archive -> m Entry
274findEntryByPathE :: MonadError String m => FilePath -> Archive -> m Entry
275+findEntryByPathE (normalise -> path) a =
275−findEntryByPathE path a = mkE ("No entry on path: " ++ path) $ findEntryByPath path a
276+ mkE ("No entry on path: " ++ path) $ findEntryByPath path a
276
277
277parseXMLDocE :: MonadError String m => String -> m Element
278parseXMLDocE :: MonadError String m => String -> m Element
278parseXMLDocE doc = mkE "Unable to parse XML doc" $ parseXMLDoc doc
279parseXMLDocE doc = mkE "Unable to parse XML doc" $ parseXMLDoc doc