From cc6dcf03928404c08cfb3075a90d814b25fd7c69 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 29 May 2021 17:36:30 -0700 Subject: Markdown reader: in rebasePaths, check for both Windows and Posix absolute paths. Previously Windows pandoc was treating `/foo/bar.jpg` as non-absolute. --- src/Text/Pandoc/Readers/Markdown.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 9a5e0889e..1761ee2c1 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -29,7 +29,9 @@ import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as T import qualified Data.ByteString.Lazy as BL -import System.FilePath (addExtension, takeExtension, isAbsolute, takeDirectory) +import System.FilePath (addExtension, takeExtension, takeDirectory) +import qualified System.FilePath.Windows as Windows +import qualified System.FilePath.Posix as Posix import Text.HTML.TagSoup hiding (Row) import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.Builder as B @@ -1924,9 +1926,8 @@ rebasePath :: SourcePos -> Text -> Text rebasePath pos path = do let fp = sourceName pos isFragment = T.take 1 path == "#" - -- check for leading / because on Windows this won't be - -- recognized as absolute by isAbsolute - isAbsolutePath = isAbsolute (T.unpack path) || T.take 1 path == "/" + path' = T.unpack path + isAbsolutePath = Posix.isAbsolute path' || Windows.isAbsolute path' in if T.null path || isFragment || isAbsolutePath || isURI path then path else -- cgit v1.2.3