aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2014-01-24 16:00:02 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2014-01-24 16:00:53 -0800
commita333d9788e0f510f681ae1b5f0f246434ee15d62 (patch)
tree67758a43d578a40e50bb9130fdc17108f16d6d44 /src/Text/Pandoc
parent9f3b2f6f5d06a4cf3142ffc74c8de4c1cc2bd928 (diff)
downloadpandoc-a333d9788e0f510f681ae1b5f0f246434ee15d62.tar.gz
ImageSize: Avoid use of lookAhead, which is not in binary >= 0.6.
Closes #1124.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/ImageSize.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Text/Pandoc/ImageSize.hs b/src/Text/Pandoc/ImageSize.hs
index 14575244d..3c9623b3c 100644
--- a/src/Text/Pandoc/ImageSize.hs
+++ b/src/Text/Pandoc/ImageSize.hs
@@ -182,15 +182,16 @@ findJfifSize bs = do
Nothing -> fail "Did not find length record"
exifSize :: ByteString -> Maybe ImageSize
-exifSize = runGet (Just <$> exifHeader) . BL.fromChunks . (:[])
+exifSize bs = runGet (Just <$> exifHeader bl) bl
+ where bl = BL.fromChunks [bs]
-- NOTE: It would be nicer to do
-- runGet ((Just <$> exifHeader) <|> return Nothing)
-- which would prevent pandoc from raising an error when an exif header can't
-- be parsed. But we only get an Alternative instance for Get in binary 0.6,
-- and binary 0.5 ships with ghc 7.6.
-exifHeader :: Get ImageSize
-exifHeader = do
+exifHeader :: BL.ByteString -> Get ImageSize
+exifHeader hdr = do
_app1DataSize <- getWord16be
exifHdr <- getWord32be
unless (exifHdr == 0x45786966) $ fail "Did not find exif header"
@@ -198,7 +199,7 @@ exifHeader = do
unless (zeros == 0) $ fail "Expected zeros after exif header"
-- beginning of tiff header -- we read whole thing to use
-- in getting data from offsets:
- tiffHeader <- lookAhead getRemainingLazyByteString
+ let tiffHeader = BL.drop 8 hdr
byteAlign <- getWord16be
let bigEndian = byteAlign == 0x4d4d
let (getWord16, getWord32, getWord64) =