Escape illegal characters in XML (#82)

This commit is contained in:
Alex Ling
2020-06-30 16:44:42 +00:00
parent c87b96dd0b
commit fe082e7537
3 changed files with 14 additions and 4 deletions
+10
View File
@@ -154,3 +154,13 @@ def ctime(file_path : String) : Time
Time.new stat.st_ctim, Time::Location::UTC
{% end %}
end
def escape_xml(str)
str.gsub({
'>' => ">",
'<' => "&lt;",
'"' => "&quot;",
'\'' => "&apos;",
'&' => "&amp;",
})
end