aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-05-28 10:40:50 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-05-28 10:41:40 -0700
commit9cf5f74e8fad9c7b898553724a37035bfc46f268 (patch)
tree434a11262eee84becd61877e713d25aede1b5240
parent63865e4670c7d4e0a3873244d8a1c3afe12ebb2a (diff)
downloadpandoc-9cf5f74e8fad9c7b898553724a37035bfc46f268.tar.gz
PDF writer: Fixed treatment of data uris for images.
Closes #1062.
-rw-r--r--pandoc.cabal3
-rw-r--r--src/Text/Pandoc/PDF.hs4
2 files changed, 4 insertions, 3 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index a2138d6bf..c834319a2 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -237,7 +237,8 @@ Library
scientific >= 0.2 && < 0.4,
vector >= 0.10 && < 0.11,
hslua >= 0.3 && < 0.4,
- binary >= 0.5 && < 0.8
+ binary >= 0.5 && < 0.8,
+ SHA >= 1.6 && < 1.7
Build-Tools: alex, happy
if flag(https)
Build-Depends: http-client >= 0.3.2 && < 0.4,
diff --git a/src/Text/Pandoc/PDF.hs b/src/Text/Pandoc/PDF.hs
index e4e06e6c9..bd55c565f 100644
--- a/src/Text/Pandoc/PDF.hs
+++ b/src/Text/Pandoc/PDF.hs
@@ -38,11 +38,11 @@ import qualified Data.ByteString as BS
import System.Exit (ExitCode (..))
import System.FilePath
import System.Directory
+import Data.Digest.Pure.SHA (showDigest, sha1)
import System.Environment
import Control.Monad (unless)
import Data.List (isInfixOf)
import Data.Maybe (fromMaybe)
-import qualified Data.ByteString.Base64 as B64
import qualified Text.Pandoc.UTF8 as UTF8
import Text.Pandoc.Definition
import Text.Pandoc.Walk (walkM)
@@ -98,7 +98,7 @@ handleImage' baseURL tmpdir (Image ils (src,tit)) = do
Right (contents, Just mime) -> do
let ext = fromMaybe (takeExtension src) $
extensionFromMimeType mime
- let basename = UTF8.toString $ B64.encode $ UTF8.fromString src
+ let basename = showDigest $ sha1 $ BL.fromChunks [contents]
let fname = tmpdir </> basename <.> ext
BS.writeFile fname contents
return $ Image ils (fname,tit)