make html safe (I have no idea how this works

This commit is contained in:
bingus_violet 2024-06-25 18:10:22 -05:00
parent e3dcd08714
commit c6ddb7fe40

View file

@ -38,6 +38,10 @@ function firstToUpper(str) {
return str.charAt(0).toUpperCase() + str.slice(1) return str.charAt(0).toUpperCase() + str.slice(1)
} }
function makeHtmlSafe(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
function timeFormatter(seconds) { function timeFormatter(seconds) {
seconds = Math.ceil(seconds) seconds = Math.ceil(seconds)
var minutes = Math.ceil(seconds / 60) var minutes = Math.ceil(seconds / 60)
@ -122,8 +126,8 @@ function highlighter(json, full = true) {
if (termProps.outline) { if (termProps.outline) {
var width = 2 var width = 2
style += `text-shadow: -1px -1px 0 ${termProps.outline}, 1px -1px 0 ${termProps.outline}, -1px 1px 0 ${termProps.outline}, 1px 1px 0 ${termProps.outline};` // style += `text-shadow: -1px -1px 0 ${termProps.outline}, 1px -1px 0 ${termProps.outline}, -1px 1px 0 ${termProps.outline}, 1px 1px 0 ${termProps.outline};`
// style += `-webkit-text-stroke: 1px ${termProps.outline};` style += `-webkit-text-stroke: 1px ${termProps.outline};`
// ^ Not in use because it looks bad :30 // ^ Not in use because it looks bad :30
} }
@ -191,7 +195,8 @@ function converter(html, dynamic = true) {
addedHTML += status.emoji.name + " " addedHTML += status.emoji.name + " "
} }
} }
addedHTML += status.state
addedHTML += makeHtmlSafe(status.state)
addedHTML += "</p>" addedHTML += "</p>"
return addedHTML return addedHTML
} }