mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Escape user input <ins> and <del> elements in logs
This commit is contained in:
@@ -80,17 +80,18 @@ export const actions: Actions = {
|
||||
|
||||
const htmlDiff = (oldValue: string, newValue: string) => {
|
||||
const diff = dmp.diff_main(oldValue, newValue);
|
||||
dmp.diff_cleanupSemantic(diff);
|
||||
|
||||
return diff
|
||||
.map(([op, text]) => {
|
||||
const escapedText = text.replace(/</g, "<").replace(/>/g, ">");
|
||||
|
||||
switch (op) {
|
||||
case 1:
|
||||
return `<ins>${text}</ins>`;
|
||||
return `<ins>${escapedText}</ins>`;
|
||||
case -1:
|
||||
return `<del>${text}</del>`;
|
||||
return `<del>${escapedText}</del>`;
|
||||
default:
|
||||
return text;
|
||||
return escapedText;
|
||||
}
|
||||
})
|
||||
.join("");
|
||||
|
||||
Reference in New Issue
Block a user