diff --git a/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js b/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js index d5bacde9..8e4c4a9d 100644 --- a/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js +++ b/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js @@ -1,4 +1,5 @@ "use strict"; -// TODO: This does not strip hex based colours - issue #1413 -module.exports = (message) => message.replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/g, "").trim(); +const matchFormatting = /\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?|\x04(?:[0-9a-f]{6}(?:,[0-9a-f]{6})?)?/gi; + +module.exports = (message) => message.replace(matchFormatting, "").trim(); diff --git a/test/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js b/test/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js index 4bca4132..5717ea78 100644 --- a/test/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js +++ b/test/client/js/libs/handlebars/ircmessageparser/cleanIrcMessage.js @@ -38,6 +38,15 @@ describe("cleanIrcMessage", function() { }, { input: "\x02#\x038,9thelounge", expected: "#thelounge", + }, { + input: "\x04DDEEAA,BBEEFF#\x038,9thelou\x04FFAACC\x0311\x04nge", + expected: "#thelounge", + }, { + input: "\x04ddEEffhex\x04 color\x04EEffCC,AAaaCC clean", + expected: "hex color clean", + }, { + input: "\x04 AAaaAA\x03 11 \x04Invalid,Hex ", + expected: "AAaaAA 11 Invalid,Hex", }]; const actual = testCases.map((testCase) => cleanIrcMessage(testCase.input));