git.iko.soy/typeable/pandoc
on master help sign in
Use uriPathToPath with file: URIs.

Closes #4613. Needs testing on Windows.

commit780bf64d1d441caf98c29f0544c1eefdb81b1cfa authorJohn MacFarlane <jgm@berkeley.edu> dateTue 8 May 2018, 09:56 (8 years ago) parent3a291da
2 files changed+4−3
src/Text/Pandoc/App.hs+2−2 src/Text/Pandoc/Class.hs+2−1
src/Text/Pandoc/App.hs+2−2
@@ -93,7 +93,7 @@ import Text.Pandoc.Highlighting (highlightingStyles)
9393import Text.Pandoc.PDF (makePDF)
9494import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained)
9595import Text.Pandoc.Shared (eastAsianLineBreakFilter, stripEmptyParagraphs,
96− headerShift, isURI, ordNub, safeRead, tabFilter)
96+ headerShift, isURI, ordNub, safeRead, tabFilter, uriPathToPath)
9797import qualified Text.Pandoc.UTF8 as UTF8
9898import Text.Pandoc.Writers.Math (defaultKaTeXURL, defaultMathJaxURL)
9999import Text.Pandoc.XML (toEntities)
@@ -795,7 +795,7 @@ readSource src = case parseURI src of
795795 readURI src
796796 | uriScheme u == "file:" ->
797797 liftIO $ UTF8.toText <$>
798− BS.readFile (uriPath u)
798+ BS.readFile (uriPathToPath $ uriPath u)
799799 _ -> liftIO $ UTF8.toText <$>
800800 BS.readFile src
801801
src/Text/Pandoc/Class.hs+2−1
@@ -110,6 +110,7 @@ import qualified Text.Pandoc.UTF8 as UTF8
110110import qualified System.Directory as Directory
111111import Data.Time (UTCTime)
112112import Text.Pandoc.Logging
113+import Text.Pandoc.Shared (uriPathToPath)
113114import Text.Parsec (ParsecT, getPosition, sourceLine, sourceName)
114115import qualified Data.Time as IO (getCurrentTime)
115116import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)
@@ -598,7 +599,7 @@ downloadOrRead s = do
598599 -- We don't want to treat C:/ as a scheme:
599600 Just u' | length (uriScheme u') > 2 -> openURL (show u')
600601 Just u' | uriScheme u' == "file:" ->
601− readLocalFile $ dropWhile (=='/') (uriPath u')
602+ readLocalFile $ uriPathToPath (uriPath u')
602603 _ -> readLocalFile fp -- get from local file system
603604 where readLocalFile f = do
604605 resourcePath <- getResourcePath