Skip to content

Commit

Permalink
replace sanitize method so that it works easily in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Feb 9, 2024
1 parent 76aa7ee commit 8ed8f91
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ function calcTextWidth(text, size = null) {
* @returns {string}
*/
function sanitize(text) {
return new Option(text).innerHTML;
return text.replace(/[\x26\x0A\<>'"]/g, function (r) {
return "&#" + r.charCodeAt(0) + ";";
});
}

/**
Expand Down

0 comments on commit 8ed8f91

Please sign in to comment.