diff options
Diffstat (limited to 'tools/dochack')
-rw-r--r-- | tools/dochack/dochack.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/dochack/dochack.nim b/tools/dochack/dochack.nim index 4c4db4638..471212a50 100644 --- a/tools/dochack/dochack.nim +++ b/tools/dochack/dochack.nim @@ -267,6 +267,19 @@ var template normalize(x: cstring): cstring = x.toLower.replace("_", "") +proc escapeCString(x: var cstring) = + var s = "" + for c in x: + case c + of '&': s.add("&") + of '<': s.add("<") + of '>': s.add(">") + of '"': s.add(""") + of '\'': s.add("'") + of '/': s.add("/") + else: s.add(c) + x = s.cstring + proc dosearch(value: cstring): Element = if db.len == 0: var stuff: Element @@ -305,6 +318,7 @@ proc dosearch(value: cstring): Element = matches.sort(proc(a, b: auto): int = b[1] - a[1]) for i in 0 ..< min(matches.len, 29): matches[i][0].innerHTML = matches[i][0].getAttribute("data-doc-search-tag") + escapeCString(matches[i][0].innerHTML) ul.add(tree("LI", cast[Element](matches[i][0]))) if ul.len == 0: result.add tree("B", text"no search results") |