From 780bf64d1d441caf98c29f0544c1eefdb81b1cfa Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 8 May 2018 09:56:17 -0700 Subject: Use uriPathToPath with file: URIs. Closes #4613. Needs testing on Windows. --- src/Text/Pandoc/App.hs | 4 ++-- src/Text/Pandoc/Class.hs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index abc732213..920462d48 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -93,7 +93,7 @@ import Text.Pandoc.Highlighting (highlightingStyles) import Text.Pandoc.PDF (makePDF) import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained) import Text.Pandoc.Shared (eastAsianLineBreakFilter, stripEmptyParagraphs, - headerShift, isURI, ordNub, safeRead, tabFilter) + headerShift, isURI, ordNub, safeRead, tabFilter, uriPathToPath) import qualified Text.Pandoc.UTF8 as UTF8 import Text.Pandoc.Writers.Math (defaultKaTeXURL, defaultMathJaxURL) import Text.Pandoc.XML (toEntities) @@ -795,7 +795,7 @@ readSource src = case parseURI src of readURI src | uriScheme u == "file:" -> liftIO $ UTF8.toText <$> - BS.readFile (uriPath u) + BS.readFile (uriPathToPath $ uriPath u) _ -> liftIO $ UTF8.toText <$> BS.readFile src diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs index 911ba98b5..4ade2dc6d 100644 --- a/src/Text/Pandoc/Class.hs +++ b/src/Text/Pandoc/Class.hs @@ -110,6 +110,7 @@ import qualified Text.Pandoc.UTF8 as UTF8 import qualified System.Directory as Directory import Data.Time (UTCTime) import Text.Pandoc.Logging +import Text.Pandoc.Shared (uriPathToPath) import Text.Parsec (ParsecT, getPosition, sourceLine, sourceName) import qualified Data.Time as IO (getCurrentTime) import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType) @@ -598,7 +599,7 @@ downloadOrRead s = do -- We don't want to treat C:/ as a scheme: Just u' | length (uriScheme u') > 2 -> openURL (show u') Just u' | uriScheme u' == "file:" -> - readLocalFile $ dropWhile (=='/') (uriPath u') + readLocalFile $ uriPathToPath (uriPath u') _ -> readLocalFile fp -- get from local file system where readLocalFile f = do resourcePath <- getResourcePath -- cgit v1.2.3