Merge pull request #1510 from idlewan/xml_escape

Escape ' and / when using escape in xmltree
This commit is contained in:
Andreas Rumpf
2014-09-01 00:27:16 +02:00

View File

@@ -151,6 +151,8 @@ proc addEscaped*(result: var string, s: string) =
of '>': result.add(">")
of '&': result.add("&")
of '"': result.add(""")
of '\'': result.add("'")
of '/': result.add("/")
else: result.add(c)
proc escape*(s: string): string =
@@ -164,6 +166,8 @@ proc escape*(s: string): string =
## ``>`` ``>``
## ``&`` ``&``
## ``"`` ``"``
## ``'`` ``'``
## ``/`` ``/``
## ------------ -------------------
result = newStringOfCap(s.len)
addEscaped(result, s)