git.iko.soy/typeable/pandoc
on master help sign in
Docx writer: ensure that `distArchive` is the one that comes with pandoc.

Previously a `reference.docx` in `~/.pandoc` (or the user data dir) would be used instead, and this could cause problems because a user-modified docx sometimes lacks vital sections that we count on the `distArchive` to supply. Closes #4182.

commit239cfb7f00773e524a659f1e266c0ff210969d1a authorJohn MacFarlane <jgm@berkeley.edu> dateThu 21 Dec 2017, 21:44 (9 years ago) parent3c10951
1 file changed+6−2
src/Text/Pandoc/Writers/Docx.hs+6−2
src/Text/Pandoc/Writers/Docx.hs+6−2
@@ -213,8 +213,12 @@ writeDocx opts doc@(Pandoc meta _) = do
213213 let doc' = walk fixDisplayMath doc
214214 username <- P.lookupEnv "USERNAME"
215215 utctime <- P.getCurrentTime
216− distArchive <- (toArchive . BL.fromStrict) <$>
217− P.readDefaultDataFile "reference.docx"
216+ distArchive <- (toArchive . BL.fromStrict) <$> do
217+ oldUserDataDir <- P.getUserDataDir
218+ P.setUserDataDir Nothing
219+ res <- P.readDefaultDataFile "reference.docx"
220+ P.setUserDataDir oldUserDataDir
221+ return res
218222 refArchive <- case writerReferenceDoc opts of
219223 Just f -> toArchive <$> P.readFileLazy f
220224 Nothing -> (toArchive . BL.fromStrict) <$>