aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-08-31 08:28:40 -0700
committerJohn MacFarlane <[email protected]>2023-08-31 08:28:40 -0700
commitbad922a69236e22b20d51c4ec0b90c5a6c038433 (patch)
tree8ca03e3ff59f5952cb1a608e157e5460d04e6363 /src
parent6666599af9fde970f5bb2435ec82eeae5b490415 (diff)
LaTeX writer: fix regression in escaping URLs.
In 3.1.6.1 the `~` was handled properly (either literally or with `%E7`). This broke in 3.1.6.2, which used URI encoding in both cases and didn't escape the `\` before `%E7`. This patch restores the former behavior: `~` isn't escaped if it isn't escaped in the original URL, and if it is, a backslash is added before `%`. Closes #9043.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX/Util.hs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Util.hs b/src/Text/Pandoc/Writers/LaTeX/Util.hs
index fbdd7a59c..8dcec54dd 100644
--- a/src/Text/Pandoc/Writers/LaTeX/Util.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Util.hs
@@ -29,7 +29,6 @@ import Text.Pandoc.Writers.LaTeX.Types (LW, WriterState(..))
import Text.Pandoc.Writers.LaTeX.Lang (toBabel)
import Text.Pandoc.Highlighting (toListingsLanguage)
import Text.DocLayout
-import Network.URI (escapeURIString)
import Text.Pandoc.Definition
import Text.Pandoc.ImageSize (showFl)
import Control.Monad.State.Strict (gets, modify)
@@ -92,15 +91,19 @@ stringToLaTeX context zs = do
'\'':_ -> cs <> "\\," <> xs -- add thin space
_ -> cs <> xs
in case x of
- '\\'| isUrl -> emitc '/' -- NB. / works as path sep even on Windows
- '#' | isUrl -> emits "\\#" -- see #9014
- '%' | isUrl -> emits "\\%" -- see #9014
- c | isUrl ->
- if c `elem` ['{', '}', '|', '^', '~', '[', ']', '`']
- then do
- emitc '\\' -- escape the % see #9014
- emits (escapeURIString (const False) [c])
- else emitc c
+ _ | isUrl ->
+ case x of
+ '\\' -> emitc '/' -- NB / works as path sep even on Windows
+ '#' -> emits "\\#" -- #9014
+ '%' -> emits "\\%" -- #9014
+ '{' -> emits "\\%7B"
+ '}' -> emits "\\%7D"
+ '|' -> emits "\\%7C"
+ '^' -> emits "\\%5E"
+ '[' -> emits "\\%5B"
+ ']' -> emits "\\%5D"
+ '`' -> emits "\\%60"
+ _ -> emitc x
'{' -> emits "\\{"
'}' -> emits "\\}"
'?' | ligatures -> -- avoid ?` ligature