diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-05-17 09:38:52 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-05-17 09:38:52 -0700 |
commit | 847167804aada52bc1af32920c83582b426ef9eb (patch) | |
tree | 56b90046f26e99b16b5f0ee15a5661a258e21307 /src/Text/Pandoc | |
parent | 7be30a40f1d3c8a2441d618e3d2a0981a63f8846 (diff) | |
download | pandoc-847167804aada52bc1af32920c83582b426ef9eb.tar.gz |
EPUB reader: unescape URIs in spine.
This should fix #2924.
Testing on the epub that caused the problem originally
would be welcome.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/EPUB.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/EPUB.hs b/src/Text/Pandoc/Readers/EPUB.hs index 144ba9ca2..149a7c00b 100644 --- a/src/Text/Pandoc/Readers/EPUB.hs +++ b/src/Text/Pandoc/Readers/EPUB.hs @@ -14,6 +14,7 @@ import Text.Pandoc.Walk (walk, query) import Text.Pandoc.Readers.HTML (readHtml) import Text.Pandoc.Options ( ReaderOptions(..), readerTrace) import Text.Pandoc.Shared (escapeURI, collapseFilePath, addMetaField) +import Network.URI (unEscapeString) import Text.Pandoc.MediaBag (MediaBag, insertMedia) import Text.Pandoc.Compat.Except (MonadError, throwError, runExcept, Except) import Text.Pandoc.Compat.Monoid ((<>)) @@ -74,14 +75,15 @@ archiveToEPUB os archive = do let docSpan = B.doc $ B.para $ B.spanWith (takeFileName path, [], []) mempty return $ docSpan <> doc mimeToReader :: MonadError PandocError m => MimeType -> FilePath -> FilePath -> m Pandoc - mimeToReader "application/xhtml+xml" (normalise -> root) (normalise -> path) = do + mimeToReader "application/xhtml+xml" (unEscapeString -> root) + (unEscapeString -> path) = do fname <- findEntryByPathE (root </> path) archive html <- either throwError return . readHtml os' . UTF8.toStringLazy $ fromEntry fname return $ fixInternalReferences path html - mimeToReader s _ path + mimeToReader s _ (unEscapeString -> path) | s `elem` imageMimes = return $ imageToPandoc path | otherwise = return $ mempty |