epub-metadata 2.3.0 → 2.3.1
raw patch · 4 files changed
+22/−5 lines, 4 filesbinary-addedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- epub-metadata.cabal +3/−3
- src/Codec/Epub/IO.hs +4/−1
- testsuite/damagedZipCentralDir.epub binary
- testsuite/opf-parse.hs +15/−1
epub-metadata.cabal view
@@ -1,5 +1,5 @@ name: epub-metadata-version: 2.3.0+version: 2.3.1 cabal-version: >= 1.8 build-type: Simple license: BSD3@@ -12,8 +12,8 @@ synopsis: Library for parsing and manipulating ePub files and OPF package data description: Library for parsing and manipulating ePub files and OPF package data. An attempt has been made here to very thoroughly implement the OPF Package Document specification. category: Codec, Text-tested-with: GHC >= 7.0.3-extra-source-files: testsuite/*.hs, testsuite/*.opf+tested-with: GHC >= 7.6.1+extra-source-files: testsuite/*.epub, testsuite/*.hs, testsuite/*.opf source-repository head type: darcs
src/Codec/Epub/IO.hs view
@@ -17,6 +17,7 @@ import Codec.Archive.Zip import Control.Arrow.ListArrows ( (>>>), deep )+import Control.Exception import Control.Monad.Error import qualified Data.ByteString.Char8 as BS import Data.ByteString.Lazy ( fromChunks )@@ -73,7 +74,9 @@ opfContentsFromBS strictBytes = do -- Need to turn this strict byte string into a lazy one let lazyBytes = fromChunks [strictBytes]- let archive = toArchive lazyBytes+ result <- liftIO $ ( try $ evaluate+ (toArchive lazyBytes) :: IO (Either SomeException Archive) )+ archive <- either (throwError . show) return result {- We need to first extract the container.xml file It's required to have a certain path and name in the epub
+ testsuite/damagedZipCentralDir.epub view
binary file changed (absent → 156 bytes)
testsuite/opf-parse.hs view
@@ -5,8 +5,9 @@ import Control.Monad.Error import System.Exit import System.FilePath-import Test.HUnit ( Counts (..), Test (..), assertEqual, runTestTT )+import Test.HUnit hiding ( counts ) +import Codec.Epub.IO import Codec.Epub.Opf.Package import Codec.Epub.Opf.Parse @@ -31,6 +32,7 @@ [ testFull , testMinimal , testMissingAll+ , testDamagedZip ] @@ -192,3 +194,15 @@ , opGuide = [] } assertEqual "missing all" expected actual+++{- Occasionally epub zip files come along that are damaged in this+ way. It's not fatal to the UNIX zip utility or to book readers, but had+ to be specially handled in the Haskell zip-archive library or it causes+ a fatal exception.+-}+testDamagedZip :: Test+testDamagedZip = TestLabel "damaged zip" $ TestCase $ do+ actual <- runErrorT $ opfContentsFromZip $ "testsuite"+ </> "damagedZipCentralDir.epub"+ actual @?= Left "Did not find end of central directory signature. Failed reading at byte position 138"