Unescape ISUPPORT values

This allows ISUPPORT values to contain spaces.

References: https://github.com/ircdocs/modern-irc/pull/137
This commit is contained in:
Simon Ser 2021-10-18 13:29:11 +02:00
parent 34aea84dde
commit 12440691c9

View file

@ -364,6 +364,13 @@ export function parseCTCP(msg) {
return ctcp;
}
function unescapeISUPPORTValue(s) {
return s.replace(/\\x[0-9A-Z]{2}/gi, (esc) => {
let hex = esc.slice(2);
return String.fromCharCode(parseInt(hex, 16));
});
}
export function parseISUPPORT(tokens, params) {
let changed = [];
tokens.forEach((tok) => {
@ -377,7 +384,7 @@ export function parseISUPPORT(tokens, params) {
let k = tok, v = "";
if (i >= 0) {
k = tok.slice(0, i);
v = tok.slice(i + 1);
v = unescapeISUPPORTValue(tok.slice(i + 1));
}
k = k.toUpperCase();