git.iko.soy/typeable/pandoc
on master help sign in
PDF: More conservative solution to #777.

Now, instead of always creating temp dirs in the home directory on Windows, we only do it if the system tempdir name contains tildes. (This will be the case for longer usernames only.) Closes #1192.

commitcb1ede5b085e1372e400f1ff3b0d52ff684f6db7 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 2 Feb 2019, 12:35 (8 years ago) parent737c0a6
1 file changed+11−2
src/Text/Pandoc/PDF.hs+11−2
src/Text/Pandoc/PDF.hs+11−2
@@ -50,7 +50,8 @@ import System.Environment
5050import System.Exit (ExitCode (..))
5151import System.FilePath
5252import System.IO (stdout)
53−import System.IO.Temp (withSystemTempDirectory, withTempFile)
53+import System.IO.Temp (withSystemTempDirectory, withTempDirectory,
54+ withTempFile)
5455#if MIN_VERSION_base(4,8,3)
5556import System.IO.Error (IOError, isDoesNotExistError)
5657#else
@@ -102,7 +103,15 @@ makePDF program pdfargs writer opts doc = do
102103 baseProg -> do
103104 commonState <- getCommonState
104105 verbosity <- getVerbosity
105− liftIO $ withSystemTempDirectory "tex2pdf." $ \tmpdir -> do
106+ -- latex has trouble with tildes in paths, which
107+ -- you find in Windows temp dir paths with longer
108+ -- user names (see #777)
109+ let withTempDir templ action = do
110+ tmp <- getTemporaryDirectory
111+ if '~' `elem` tmp
112+ then withTempDirectory "." templ action
113+ else withSystemTempDirectory templ action
114+ liftIO $ withTempDir "tex2pdf." $ \tmpdir -> do
106115 source <- runIOorExplode $ do
107116 putCommonState commonState
108117 doc' <- handleImages tmpdir doc