git.iko.soy/typeable/pandoc
on master help sign in
EPUB reader: unescape URIs in spine.

This should fix #2924. Testing on the epub that caused the problem originally would be welcome.

commit847167804aada52bc1af32920c83582b426ef9eb authorJohn MacFarlane <jgm@berkeley.edu> dateTue 17 May 2016, 09:38 (10 years ago) parent7be30a4
1 file changed+4−2
src/Text/Pandoc/Readers/EPUB.hs+4−2
src/Text/Pandoc/Readers/EPUB.hs+4−2
@@ -14,6 +14,7 @@ import Text.Pandoc.Walk (walk, query)
1414import Text.Pandoc.Readers.HTML (readHtml)
1515import Text.Pandoc.Options ( ReaderOptions(..), readerTrace)
1616import Text.Pandoc.Shared (escapeURI, collapseFilePath, addMetaField)
17+import Network.URI (unEscapeString)
1718import Text.Pandoc.MediaBag (MediaBag, insertMedia)
1819import Text.Pandoc.Compat.Except (MonadError, throwError, runExcept, Except)
1920import Text.Pandoc.Compat.Monoid ((<>))
@@ -74,14 +75,15 @@ archiveToEPUB os archive = do
7475 let docSpan = B.doc $ B.para $ B.spanWith (takeFileName path, [], []) mempty
7576 return $ docSpan <> doc
7677 mimeToReader :: MonadError PandocError m => MimeType -> FilePath -> FilePath -> m Pandoc
77− mimeToReader "application/xhtml+xml" (normalise -> root) (normalise -> path) = do
78+ mimeToReader "application/xhtml+xml" (unEscapeString -> root)
79+ (unEscapeString -> path) = do
7880 fname <- findEntryByPathE (root </> path) archive
7981 html <- either throwError return .
8082 readHtml os' .
8183 UTF8.toStringLazy $
8284 fromEntry fname
8385 return $ fixInternalReferences path html
84− mimeToReader s _ path
86+ mimeToReader s _ (unEscapeString -> path)
8587 | s `elem` imageMimes = return $ imageToPandoc path
8688 | otherwise = return $ mempty
8789