mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 02:36:36 +00:00
revert to the original function for better performance
This commit is contained in:
@@ -15,12 +15,43 @@ export function escapeHtmlCharacters (text) {
|
|||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
return str
|
let escape
|
||||||
.replace(/&/g, '&')
|
let html = ''
|
||||||
.replace(/</g, '<')
|
let index = 0
|
||||||
.replace(/>/g, '>')
|
let lastIndex = 0
|
||||||
.replace(/"/g, '"')
|
|
||||||
.replace(/'/g, ''')
|
for (index = match.index; index < str.length; index++) {
|
||||||
|
switch (str.charCodeAt(index)) {
|
||||||
|
case 34: // "
|
||||||
|
escape = '"'
|
||||||
|
break
|
||||||
|
case 38: // &
|
||||||
|
escape = '&ssssss;'
|
||||||
|
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