fix #16364 (#16379) [backport]

* fix #16364

* add comments

* Update tools/dochack/dochack.nim

Co-authored-by: Clyybber <darkmine956@gmail.com>

Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
flywind
2020-12-17 14:14:16 -06:00
committed by GitHub
parent e1e069dd6c
commit 5d8f862bc6

View File

@@ -268,15 +268,13 @@ var
template normalize(x: cstring): cstring = x.toLower.replace("_", "")
proc escapeCString(x: var cstring) =
# Original strings are already escaped except HTML tags, so
# we only escape `<` and `>`.
var s = ""
for c in x:
case c
of '&': s.add("&amp;")
of '<': s.add("&lt;")
of '>': s.add("&gt;")
of '"': s.add("&quot;")
of '\'': s.add("&#039;")
of '/': s.add("&#x2F;")
else: s.add(c)
x = s.cstring