fix escape filter with stringify

This commit is contained in:
jamelait
2019-08-25 04:19:37 -05:00
committed by Jun Yang
parent aa15f3dfe1
commit e17bc97d8e
+3 -1
View File
@@ -1,3 +1,5 @@
import { stringify } from '../../util/underscore'
const escapeMap = { const escapeMap = {
'&': '&', '&': '&',
'<': '&lt;', '<': '&lt;',
@@ -14,7 +16,7 @@ const unescapeMap = {
} }
function escape (str: string) { function escape (str: string) {
return str ? String(str).replace(/&|<|>|"|'/g, m => escapeMap[m]) : '' return stringify(str).replace(/&|<|>|"|'/g, m => escapeMap[m])
} }
function unescape (str: string) { function unescape (str: string) {