diff --git a/lib/channel/playlist.js b/lib/channel/playlist.js index ae9c12f1..4d8ffff0 100644 --- a/lib/channel/playlist.js +++ b/lib/channel/playlist.js @@ -1243,6 +1243,8 @@ PlaylistModule.prototype.handleClonePlaylist = function (user, data) { }); } + data.name = data.name.replace(/[^\u0000-\uffff]/g, "?"); + var pl = this.items.toArray(); var self = this; db.saveUserPlaylist(pl, user.getName(), data.name, function (err) { diff --git a/lib/database.js b/lib/database.js index 1faecbac..b77b68f8 100644 --- a/lib/database.js +++ b/lib/database.js @@ -17,7 +17,8 @@ module.exports.init = function () { user: Config.get("mysql.user"), password: Config.get("mysql.password"), database: Config.get("mysql.database"), - multipleStatements: true + multipleStatements: true, + charset: "UTF8MB4_GENERAL_CI" // Needed for emoji and other non-BMP unicode }); // Test the connection diff --git a/lib/database/tables.js b/lib/database/tables.js index 4fbd7a09..0b4cb841 100644 --- a/lib/database/tables.js +++ b/lib/database/tables.js @@ -5,7 +5,7 @@ const TBL_USERS = "" + "`password` VARCHAR(64) NOT NULL," + "`global_rank` INT NOT NULL," + "`email` VARCHAR(255) NOT NULL," + - "`profile` TEXT NOT NULL," + + "`profile` TEXT CHARACTER SET utf8mb4 NOT NULL," + "`ip` VARCHAR(39) NOT NULL," + "`time` BIGINT NOT NULL," + "PRIMARY KEY(`id`)," + "UNIQUE(`name`)) " + @@ -23,7 +23,7 @@ const TBL_CHANNELS = "" + const TBL_GLOBAL_BANS = "" + "CREATE TABLE IF NOT EXISTS `global_bans` (" + "`ip` VARCHAR(39) NOT NULL," + - "`reason` VARCHAR(255) NOT NULL," + + "`reason` VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL," + "PRIMARY KEY (`ip`)) " + "CHARACTER SET utf8"; @@ -75,7 +75,7 @@ const TBL_META = "" + const TBL_LIBRARIES = "" + "CREATE TABLE IF NOT EXISTS `channel_libraries` (" + "`id` VARCHAR(255) NOT NULL," + - "`title` VARCHAR(255) NOT NULL," + + "`title` VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL," + "`seconds` INT NOT NULL," + "`type` VARCHAR(2) NOT NULL," + "`meta` TEXT NOT NULL," + @@ -97,7 +97,7 @@ const TBL_BANS = "" + "`ip` VARCHAR(39) NOT NULL," + "`name` VARCHAR(20) NOT NULL," + "`bannedby` VARCHAR(20) NOT NULL," + - "`reason` VARCHAR(255) NOT NULL," + + "`reason` VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL," + "`channel` VARCHAR(30) NOT NULL," + "PRIMARY KEY (`id`, `channel`), UNIQUE (`name`, `ip`, `channel`), " + "INDEX (`ip`, `channel`), INDEX (`name`, `channel`)" +