aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-05-08 09:56:17 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-05-08 09:56:42 -0700
commit780bf64d1d441caf98c29f0544c1eefdb81b1cfa (patch)
tree9a5c55ae8a5a8d5aaf7251f04d946d01a3bbab85 /src/Text/Pandoc
parent3a291dad3534b6936731b54276b185214a1d6298 (diff)
downloadpandoc-780bf64d1d441caf98c29f0544c1eefdb81b1cfa.tar.gz
Use uriPathToPath with file: URIs.
Closes #4613. Needs testing on Windows.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/App.hs4
-rw-r--r--src/Text/Pandoc/Class.hs3
2 files changed, 4 insertions, 3 deletions
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