diff --git a/src/d2m/converters/user-to-mxid.js b/src/d2m/converters/user-to-mxid.js
index 12891c0..7705aff 100644
--- a/src/d2m/converters/user-to-mxid.js
+++ b/src/d2m/converters/user-to-mxid.js
@@ -20,10 +20,10 @@ const SPECIAL_USER_MAPPINGS = new Map([
function downcaseUsername(user) {
// First, try to convert the username to the set of allowed characters
let downcased = user.username.toLowerCase()
- // spaces to underscores...
- .replace(/ /g, "_")
+ // spaces and slashes to underscores...
+ .replace(/[ /]/g, "_")
// remove disallowed characters...
- .replace(/[^a-z0-9._=/-]*/g, "")
+ .replace(/[^a-z0-9._=-]*/g, "")
// remove leading and trailing dashes and underscores...
.replace(/(?:^[_-]*|[_-]*$)/g, "")
// If requested, also make the Discord user ID part of the username
diff --git a/src/d2m/converters/user-to-mxid.test.js b/src/d2m/converters/user-to-mxid.test.js
index 387d472..f8cf16a 100644
--- a/src/d2m/converters/user-to-mxid.test.js
+++ b/src/d2m/converters/user-to-mxid.test.js
@@ -21,8 +21,12 @@ test("user2name: works on single emoji at the end", t => {
t.equal(userToSimName({username: "Melody 🎵", discriminator: "2192"}), "melody")
})
-test("user2name: works on crazy name", t => {
- t.equal(userToSimName({username: "*** D3 &W (89) _7//-", discriminator: "0001"}), "d3_w_89__7//")
+test("user2name: works on really weird name", t => {
+ t.equal(userToSimName({username: "*** D3 &W (89) _7//-", discriminator: "0001"}), "d3_w_89__7")
+})
+
+test("user2name: treats slashes", t => {
+ t.equal(userToSimName({username: "Evil Lillith (she/her)", discriminator: "5892"}), "evil_lillith_she_her")
})
test("user2name: adds discriminator if name is unavailable (old tag format)", t => {
diff --git a/src/db/migrations/0034-slash-not-allowed-in-mxid.sql b/src/db/migrations/0034-slash-not-allowed-in-mxid.sql
new file mode 100644
index 0000000..ea2d031
--- /dev/null
+++ b/src/db/migrations/0034-slash-not-allowed-in-mxid.sql
@@ -0,0 +1,5 @@
+BEGIN TRANSACTION;
+
+DELETE FROM sim WHERE sim_name like '%/%';
+
+COMMIT;
|