mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
fixed double escape html
This commit is contained in:
@@ -15,43 +15,12 @@ export function escapeHtmlCharacters (text) {
|
|||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
let escape
|
return str
|
||||||
let html = ''
|
.replace(/&/g, '&')
|
||||||
let index = 0
|
.replace(/</g, '<')
|
||||||
let lastIndex = 0
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
for (index = match.index; index < str.length; index++) {
|
.replace(/'/g, ''')
|
||||||
switch (str.charCodeAt(index)) {
|
|
||||||
case 34: // "
|
|
||||||
escape = '"'
|
|
||||||
break
|
|
||||||
case 38: // &
|
|
||||||
escape = '&'
|
|
||||||
break
|
|
||||||
case 39: // '
|
|
||||||
escape = '''
|
|
||||||
break
|
|
||||||
case 60: // <
|
|
||||||
escape = '<'
|
|
||||||
break
|
|
||||||
case 62: // >
|
|
||||||
escape = '>'
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lastIndex !== index) {
|
|
||||||
html += str.substring(lastIndex, index)
|
|
||||||
}
|
|
||||||
|
|
||||||
lastIndex = index + 1
|
|
||||||
html += escape
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastIndex !== index
|
|
||||||
? html + str.substring(lastIndex, index)
|
|
||||||
: html
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
Reference in New Issue
Block a user