aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-04-04 16:13:24 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-04-04 16:13:24 +0200
commit1ebb766aff22590874b9660322f1788c3698649a (patch)
tree369adc05fbea0c152dc4a9b55e17a8858ee3e8b0 /src/Text/Pandoc/Writers
parente650d1fbfd2e2486dac939638bde5c0d325da8a9 (diff)
downloadpandoc-1ebb766aff22590874b9660322f1788c3698649a.tar.gz
Ms writer: ensure that @ is escaped in URIs.
Otherwise we may get unescaped @s that give eqn fits, with @ as the delimiter character.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Ms.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs
index 00be502b3..aadbd208e 100644
--- a/src/Text/Pandoc/Writers/Ms.hs
+++ b/src/Text/Pandoc/Writers/Ms.hs
@@ -57,6 +57,7 @@ import Text.TeXMath (writeEqn)
import System.FilePath (takeExtension)
import Skylighting
import Text.Pandoc.Highlighting
+import Network.URI (escapeURIString, isAllowedInURI)
data WriterState = WriterState { stHasInlineMath :: Bool
, stFirstPara :: Bool
@@ -157,6 +158,9 @@ escapeBar = concatMap go
escapeString :: String -> String
escapeString = concatMap escapeChar
+escapeUri :: String -> String
+escapeUri = escapeURIString (\c -> c /= '@' && isAllowedInURI c)
+
toSmallCaps :: String -> String
toSmallCaps [] = []
toSmallCaps (c:cs)
@@ -509,7 +513,7 @@ inlineToMs opts (Link _ txt (src, _)) = do
-- external link
contents <- inlineListToMs' opts $ map breakToSpace txt
return $ text "\\c" <> cr <> nowrap (text ".pdfhref W -D " <>
- doubleQuotes (text src) <> text " -A " <>
+ doubleQuotes (text (escapeUri src)) <> text " -A " <>
doubleQuotes (text "\\c") <> space <> text "\\") <> cr <>
text " -- " <> doubleQuotes (nowrap contents) <> cr <> text "\\&"
inlineToMs opts (Image attr alternate (source, tit)) = do