git.iko.soy/typeable/pandoc
on master help sign in
Ms writer: ensure that @ is escaped in URIs.

Otherwise we may get unescaped @s that give eqn fits, with @ as the delimiter character.

commit1ebb766aff22590874b9660322f1788c3698649a authorJohn MacFarlane <jgm@berkeley.edu> dateTue 4 Apr 2017, 16:13 (10 years ago) parente650d1f
2 files changed+7−3
src/Text/Pandoc/Writers/Ms.hs+5−1 test/writer.ms+2−2
src/Text/Pandoc/Writers/Ms.hs+5−1
@@ -57,6 +57,7 @@ import Text.TeXMath (writeEqn)
5757import System.FilePath (takeExtension)
5858import Skylighting
5959import Text.Pandoc.Highlighting
60+import Network.URI (escapeURIString, isAllowedInURI)
6061
6162data WriterState = WriterState { stHasInlineMath :: Bool
6263 , stFirstPara :: Bool
@@ -157,6 +158,9 @@ escapeBar = concatMap go
157158escapeString :: String -> String
158159escapeString = concatMap escapeChar
159160
161+escapeUri :: String -> String
162+escapeUri = escapeURIString (\c -> c /= '@' && isAllowedInURI c)
163+
160164toSmallCaps :: String -> String
161165toSmallCaps [] = []
162166toSmallCaps (c:cs)
@@ -509,7 +513,7 @@ inlineToMs opts (Link _ txt (src, _)) = do
509513 -- external link
510514 contents <- inlineListToMs' opts $ map breakToSpace txt
511515 return $ text "\\c" <> cr <> nowrap (text ".pdfhref W -D " <>
512− doubleQuotes (text src) <> text " -A " <>
516+ doubleQuotes (text (escapeUri src)) <> text " -A " <>
513517 doubleQuotes (text "\\c") <> space <> text "\\") <> cr <>
514518 text " -- " <> doubleQuotes (nowrap contents) <> cr <> text "\\&"
515519inlineToMs opts (Image attr alternate (source, tit)) = do
test/writer.ms+2−2
@@ -829,7 +829,7 @@ Just a \c
829829\&
830830.PP
831831\c
832−.pdfhref W -D "mailto:nobody@nowhere.net" -A "\c" \
832+.pdfhref W -D "mailto:nobody%40nowhere.net" -A "\c" \
833833 -- "Email link"
834834\&
835835.PP
@@ -943,7 +943,7 @@ In a list?
943943It should.
944944.LP
945945An e\-mail address: \c
946−.pdfhref W -D "mailto:nobody@nowhere.net" -A "\c" \
946+.pdfhref W -D "mailto:nobody%40nowhere.net" -A "\c" \
947947 -- "nobody\@nowhere.net"
948948\&
949949.RS