From 0ee54549af0d012e60a7a750ebc939799125850e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 25 Mar 2013 20:09:24 -0700 Subject: SelfContained: strip off fragment, query of relative URL before treating as a filename. This fixes `--self-contained` when used with CSS files that include web fonts using the method described here: http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/ Examples from reveal.js themes: "../../lib/font/league_gothic-webfont.eot?#iefix" "../../lib/font/league_gothic-webfont.svg#LeagueGothicRegular" Closes #739. --- src/Text/Pandoc/SelfContained.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/SelfContained.hs b/src/Text/Pandoc/SelfContained.hs index 780d2de33..f1118b974 100644 --- a/src/Text/Pandoc/SelfContained.hs +++ b/src/Text/Pandoc/SelfContained.hs @@ -104,11 +104,15 @@ getItem userdata f = if isAbsoluteURI f then openURL f else do - let mime = case takeExtension f of - ".gz" -> getMimeType $ dropExtension f + -- strip off trailing query or fragment part, if relative URL. + -- this is needed for things like cmunrm.eot?#iefix, + -- which is used to get old versions of IE to work with web fonts. + let f' = takeWhile (\c -> c /= '?' && c /= '#') f + let mime = case takeExtension f' of + ".gz" -> getMimeType $ dropExtension f' x -> getMimeType x - exists <- doesFileExist f - cont <- if exists then B.readFile f else readDataFile userdata f + exists <- doesFileExist f' + cont <- if exists then B.readFile f' else readDataFile userdata f' return (cont, mime) getRaw :: Maybe FilePath -> String -> String -> IO (ByteString, String) -- cgit v1.2.3