@@ -105,6 +105,7 @@ import Network.HTTP (findHeader, rspBody,
105105import Network.Browser (browse, setAllowRedirects, request)
106106#ifdef EMBED_DATA_FILES
107107import Text.Pandoc.Data (dataFiles)
108+import System.FilePath ( joinPath )
108109#else
109110import Paths_pandoc (getDataFileName)
110111#endif
@@ -521,10 +522,15 @@ inDirectory path action = do
521522readDefaultDataFile :: FilePath -> IO B.ByteString
522523readDefaultDataFile fname =
523524#ifdef EMBED_DATA_FILES
524− case lookup fname dataFiles of
525+ case lookup (makeCanonical fname) dataFiles of
525526 Nothing -> ioError $ userError
526527 $ "Data file `" ++ fname ++ "' does not exist"
527528 Just contents -> return contents
529+ where makeCanonical = joinPath . transformPathParts . splitBy (=='/')
530+ transformPathParts = reverse . foldl go []
531+ go as "." = as
532+ go (_:as) ".." = as
533+ go as x = x : as
528534#else
529535 getDataFileName ("data" </> fname) >>= B.readFile
530536#endif