git.iko.soy/typeable/pandoc
on master help sign in
Docx reader: fix paths in archive to prevent Windows failure

Some paths in archives are absolute (have an opening slash) which, for reasons unknown, produces a failure in the test suite on MS Windows. This fixes that by removing the leading slash if it exists. Closes #5277 (previously closed with 4cce0ef but reopened due to this bug).

commitb3d015e266b3a271770d53e2242c24a857cb23c1 authorJesse Rosenthal <jrosenthal@jhu.edu> dateFri 8 Feb 2019, 07:31 (8 years ago) parent0719807
1 file changed+6−1
src/Text/Pandoc/Readers/Docx/Parse.hs+6−1
src/Text/Pandoc/Readers/Docx/Parse.hs+6−1
@@ -381,7 +381,12 @@ getDocumentXmlPath zf = do
381381 filter (\e -> findAttr (QName "Type" Nothing Nothing) e ==
382382 Just "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument")
383383 rels
384− findAttr (QName "Target" Nothing Nothing) rel
384+ fp <- findAttr (QName "Target" Nothing Nothing) rel
385+ -- sometimes there will be a leading slash, which windows seems to
386+ -- have trouble with.
387+ return $ case fp of
388+ '/' : fp' -> fp'
389+ _ -> fp
385390
386391archiveToDocument :: Archive -> D Document
387392archiveToDocument zf = do