Use strings.Replacer to unescape tags

This commit is contained in:
Ken-Håvard Lieng 2019-01-11 02:19:57 +01:00
parent 0085cea5a1
commit e4d5d2737b

View File

@ -151,11 +151,14 @@ func splitParam(param string) (string, string) {
return parts[0], ""
}
var unescapeTagReplacer = strings.NewReplacer(
"\\:", ";",
"\\s", " ",
"\\\\", "\\",
"\\r", "\r",
"\\n", "\n",
)
func unescapeTag(s string) string {
s = strings.Replace(s, "\\:", ";", -1)
s = strings.Replace(s, "\\s", " ", -1)
s = strings.Replace(s, "\\\\", "\\", -1)
s = strings.Replace(s, "\\r", "\r", -1)
s = strings.Replace(s, "\\n", "\n", -1)
return s
return unescapeTagReplacer.Replace(s)
}