diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts
index 6750a002..1cc4a538 100644
--- a/util/src/entities/Channel.ts
+++ b/util/src/entities/Channel.ts
@@ -162,19 +162,21 @@ export class Channel extends BaseClass {
if (!opts?.skipNameChecks) {
const guild = await Guild.findOneOrFail({ id: channel.guild_id });
if (!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name) {
-
for (var character of InvisibleCharacters)
- channel.name = channel.name.split(character).join("-");
+ if (channel.name.includes(character))
+ throw new HTTPError("Channel name cannot include invalid characters", 403);
+
+ if (channel.name.match(/\-\-+/g))
+ throw new HTTPError("Channel name cannot include multiple adjacent dashes.", 403)
- channel.name = channel.name.split(/\-+/g).join("-"); //replace multiple occurances with just one
- channel.name = channel.name.split("-").filter(Boolean).join("-"); //trim '-' character
+ if (channel.name.charAt(0) === "-" ||
+ channel.name.charAt(channel.name.length - 1) === "-")
+ throw new HTTPError("Channel name cannot start/end with dash.", 403)
}
if (!guild.features.includes("ALLOW_UNNAMED_CHANNELS")) {
-
- if (channel.name) channel.name = channel.name.trim();
-
- if (!channel.name) throw new HTTPError("Channel name cannot be empty.");
+ if (!channel.name)
+ throw new HTTPError("Channel name cannot be empty.", 403);
}
}
diff --git a/util/src/util/InvisibleCharacters.ts b/util/src/util/InvisibleCharacters.ts
index 147f51c2..2b014e14 100644
--- a/util/src/util/InvisibleCharacters.ts
+++ b/util/src/util/InvisibleCharacters.ts
@@ -1,55 +1,56 @@
+// List from https://invisible-characters.com/
export const InvisibleCharacters = [
- "\t",
- " ",
- "",
- "͏",
- "",
- "ᅟ",
- "ᅠ",
- "឴",
- "឵",
- "",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- "",
- "",
- "",
- "",
- "",
- " ",
- " ",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- " ",
- "⠀",
- "ㅤ",
- "",
- "ᅠ",
- "𝅙",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- ""
-]
\ No newline at end of file
+ '\u{9}', //Tab
+ '\u{20}', //Space
+ '\u{ad}', //Soft hyphen
+ '\u{34f}', //Combining grapheme joiner
+ '\u{61c}', //Arabic letter mark
+ '\u{115f}', //Hangul choseong filler
+ '\u{1160}', //Hangul jungseong filler
+ '\u{17b4}', //Khmer vowel inherent AQ
+ '\u{17b5}', //Khmer vowel inherent AA
+ '\u{180e}', //Mongolian vowel separator
+ '\u{2000}', //En quad
+ '\u{2001}', //Em quad
+ '\u{2002}', //En space
+ '\u{2003}', //Em space
+ '\u{2004}', //Three-per-em space
+ '\u{2005}', //Four-per-em space
+ '\u{2006}', //Six-per-em space
+ '\u{2007}', //Figure space
+ '\u{2008}', //Punctuation space
+ '\u{2009}', //Thin space
+ '\u{200a}', //Hair space
+ '\u{200b}', //Zero width space
+ '\u{200c}', //Zero width non-joiner
+ '\u{200d}', //Zero width joiner
+ '\u{200e}', //Left-to-right mark
+ '\u{200f}', //Right-to-left mark
+ '\u{202f}', //Narrow no-break space
+ '\u{205f}', //Medium mathematical space
+ '\u{2060}', //Word joiner
+ '\u{2061}', //Function application
+ '\u{2062}', //Invisible times
+ '\u{2063}', //Invisible separator
+ '\u{2064}', //Invisible plus
+ '\u{206a}', //Inhibit symmetric swapping
+ '\u{206b}', //Activate symmetric swapping
+ '\u{206c}', //Inhibit arabic form shaping
+ '\u{206d}', //Activate arabic form shaping
+ '\u{206e}', //National digit shapes
+ '\u{206f}', //Nominal digit shapes
+ '\u{3000}', //Ideographic space
+ '\u{2800}', //Braille pattern blank
+ '\u{3164}', //Hangul filler
+ '\u{feff}', //Zero width no-break space
+ '\u{ffa0}', //Haldwidth hangul filler
+ '\u{1d159}', //Musical symbol null notehead
+ '\u{1d173}', //Musical symbol begin beam
+ '\u{1d174}', //Musical symbol end beam
+ '\u{1d175}', //Musical symbol begin tie
+ '\u{1d176}', //Musical symbol end tie
+ '\u{1d177}', //Musical symbol begin slur
+ '\u{1d178}', //Musical symbol end slur
+ '\u{1d179}', //Musical symbol begin phrase
+ '\u{1d17a}' //Musical symbol end phrase
+];
\ No newline at end of file
|