Use uriPathToPath with file: URIs.

Closes #4613.

Needs testing on Windows.
This commit is contained in:
John MacFarlane
2018-05-08 09:56:42 -07:00
parent 3a291dad35
commit 780bf64d1d
2 changed files with 4 additions and 3 deletions
+2 -2
View File
@@ -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
+2 -1
View File
@@ -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