escape special html characters in addon-serialize

This commit is contained in:
sawka
2024-03-29 00:30:29 -07:00
parent 53bc9f8442
commit cdb45c743f
2 changed files with 19 additions and 1 deletions
+9 -1
View File
@@ -14,6 +14,14 @@ function constrain(value: number, low: number, high: number): number {
return Math.max(low, Math.min(value, high));
}
function escapeHtmlChar(c: string): string {
switch (c) {
case '&': return '&';
case '<': return '&lt;';
}
return c;
}
// TODO: Refine this template class later
abstract class BaseSerializeHandler {
constructor(
@@ -669,7 +677,7 @@ export class HTMLSerializeHandler extends BaseSerializeHandler {
if (isEmptyCell) {
this._currentRow += ' ';
} else {
this._currentRow += cell.getChars();
this._currentRow += escapeHtmlChar(cell.getChars());
}
}