aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-12-21 21:44:13 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-12-21 21:44:13 -0800
commit239cfb7f00773e524a659f1e266c0ff210969d1a (patch)
tree39ec927daaec01bb17643f3c320f13ba7c828039 /src/Text/Pandoc
parent3c10951023bc9767a0281b861b53e2014e7b350c (diff)
downloadpandoc-239cfb7f00773e524a659f1e266c0ff210969d1a.tar.gz
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.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index 94529dad4..e4240ca4f 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -213,8 +213,12 @@ writeDocx opts doc@(Pandoc meta _) = do
let doc' = walk fixDisplayMath doc
username <- P.lookupEnv "USERNAME"
utctime <- P.getCurrentTime
- distArchive <- (toArchive . BL.fromStrict) <$>
- P.readDefaultDataFile "reference.docx"
+ distArchive <- (toArchive . BL.fromStrict) <$> do
+ oldUserDataDir <- P.getUserDataDir
+ P.setUserDataDir Nothing
+ res <- P.readDefaultDataFile "reference.docx"
+ P.setUserDataDir oldUserDataDir
+ return res
refArchive <- case writerReferenceDoc opts of
Just f -> toArchive <$> P.readFileLazy f
Nothing -> (toArchive . BL.fromStrict) <$>