about summary refs log tree commit diff stats
path: root/adapter/protocol/man.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-05-22 16:43:58 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-22 16:43:58 +0200
commit3ec6c18c81853b52ff9dbc9ecccc890a9534322c (patch)
tree64c52f27094f34a066a91d951042648e86ae62fd /adapter/protocol/man.nim
parenta42a60c2647b4193661986f89b6405199802ab32 (diff)
downloadchawan-3ec6c18c81853b52ff9dbc9ecccc890a9534322c.tar.gz
man: quote keyword & section
Diffstat (limited to 'adapter/protocol/man.nim')
-rw-r--r--adapter/protocol/man.nim10
1 files changed, 5 insertions, 5 deletions
diff --git a/adapter/protocol/man.nim b/adapter/protocol/man.nim
index 6a6acf04..a5b7dab9 100644
--- a/adapter/protocol/man.nim
+++ b/adapter/protocol/man.nim
@@ -275,9 +275,9 @@ proc myOpen(cmd: string): tuple[ofile, efile: File] =
     return (ofile, efile)
 
 proc doMan(man, keyword, section: string) =
-  let sectionOpt = if section == "": "" else: ' ' & section
+  let sectionOpt = if section == "": "" else: ' ' & quoteShellPosix(section)
   let cmd = "MANCOLOR=1 GROFF_NO_SGR=1 MAN_KEEP_FORMATTING=1 " &
-    man & sectionOpt & ' ' & keyword
+    man & sectionOpt & ' ' & quoteShellPosix(keyword)
   let (ofile, efile) = myOpen(cmd)
   if ofile == nil:
     stdout.write("Cha-Control: ConnectionError 1 failed to run " & cmd)
@@ -294,7 +294,7 @@ proc doLocal(man, path: string) =
   # Note: we intentionally do not use -l, because it is not supported on
   # various systems (at the very least FreeBSD, NetBSD).
   let cmd = "MANCOLOR=1 GROFF_NO_SGR=1 MAN_KEEP_FORMATTING=1 " &
-    man & ' ' & path
+    man & ' ' & quoteShellPosix(path)
   let (ofile, efile) = myOpen(cmd)
   if ofile == nil:
     stdout.write("Cha-Control: ConnectionError 1 failed to run " & cmd)
@@ -305,8 +305,8 @@ proc doLocal(man, path: string) =
 <pre>""", keyword = path.afterLast('/').until('.'))
 
 proc doKeyword(man, keyword, section: string) =
-  let sectionOpt = if section == "": "" else: " -s " & section
-  let cmd = man & sectionOpt & " -k " & keyword
+  let sectionOpt = if section == "": "" else: " -s " & quoteShellPosix(section)
+  let cmd = man & sectionOpt & " -k " & quoteShellPosix(keyword)
   let (ofile, efile) = myOpen(cmd)
   if ofile == nil:
     stdout.write("Cha-Control: ConnectionError 1 failed to run " & cmd)