diff --git a/spec/unit/formatting.spec.js b/spec/unit/formatting.spec.js index a2e5a923d..27ea52491 100644 --- a/spec/unit/formatting.spec.js +++ b/spec/unit/formatting.spec.js @@ -60,6 +60,11 @@ describe("Formatting", function() { formatting.ircToHtml("The quick brown \u0002fox\u000f jumps over the lazy \u0002dog\u000f.") ).toBe("The quick brown fox jumps over the lazy dog."); }); + it("should for strikethrough inputs", function() { + expect( + formatting.ircToHtml("The quick brown \u001efox\u000f jumps over the lazy \u001edog\u000f.") + ).toBe("The quick brown fox jumps over the lazy dog."); + }); it("should for monospace inputs", function() { expect( formatting.ircToHtml("The quick brown \u0011fox\u000f jumps over the lazy \u0011dog\u000f.") diff --git a/src/irc/formatting.ts b/src/irc/formatting.ts index 136b7f18c..1456289c2 100644 --- a/src/irc/formatting.ts +++ b/src/irc/formatting.ts @@ -167,7 +167,7 @@ export function htmlToIrc(html?: string): string|null { // things like case-sensitivity and spacing). Use he to decode any html entities // because we don't want those. let cleanHtml = he.decode(sanitizeHtml(html, { - allowedTags: ["b", "code", "i", "u", "strong", "font", "em"], + allowedTags: ["b", "code", "del", "i", "u", "strong", "font", "em"], allowedAttributes: { font: ["color"] } @@ -262,13 +262,13 @@ export function ircToHtml(text: string): string { // Replace all mIRC formatting characters. // The color character can have arguments. // The regex matches: - // - Any single 'simple' formatting character: \x02, \x11, \x1d, \x1f, \x0f and - // \x16 for bold, italics, underline, reset and reverse respectively. + // - Any single 'simple' formatting character: \x02, \x11, \x1d, \x1e, \x1f, \x0f and + // \x16 for bold, italics, underline, strikethrough, reset and reverse respectively. // - The colour formatting character (\x03) followed by 0 to 2 digits for // the foreground colour and (optionally) a comma and 1-2 digits for the // background colour. // eslint-disable-next-line no-control-regex - const colorRegex = /[\x02\x11\x1d\x1f\x0f\x16]|\x03(\d{0,2})(?:,(\d{1,2}))?/g; + const colorRegex = /[\x02\x11\x1d\x1e\x1f\x0f\x16]|\x03(\d{0,2})(?:,(\d{1,2}))?/g; // Maintain a small state machine of which tags are open so we can close the right // ones on RESET codes and toggle appropriately if they do the same code again.