diff --git a/commands/profile.js b/commands/profile.js index eefe848..5eed598 100644 --- a/commands/profile.js +++ b/commands/profile.js @@ -29,10 +29,10 @@ module.exports = { let profile = await user.getProfile(); let customStatus = profile.customStatus.replace(/(.{0,40}[\s])/g, '$1'); - + let profileTemplate = fs.readFileSync('/app/assets/profile/profile.svg').toString(); - profileTemplate = profileTemplate.replace(/{{USERNAME}}/g, discordUser.username.substr(0,15)+(discordUser.username.length>15?'...':'')); - profileTemplate = profileTemplate.replace(/{{PROFILE_TEXT}}/g, customStatus ); + profileTemplate = profileTemplate.replace(/{{USERNAME}}/g, this.encodeStr(discordUser.username.substr(0,15)+(discordUser.username.length>15?'...':''))); + profileTemplate = profileTemplate.replace(/{{PROFILE_TEXT}}/g, this.encodeStr(customStatus) ); profileTemplate = profileTemplate.replace(/{{HEADER_COLOR}}/g, '190,31,97'); profileTemplate = profileTemplate.replace(/{{CC}}/g, await Card.count({where: {userId: user.id}})); profileTemplate = profileTemplate.replace(/{{LVL}}/g, await user.level().currentLevel); @@ -64,5 +64,16 @@ module.exports = { let profileImage = await Compositing.renderProfile(profile, background, renderedCards); await interaction.editReply({ files: [profileImage] }); + }, + encodeStr: function(str) { + let charMapping = { + '&': '&', + '"': '"', + '<': '<', + '>': '>' + }; + return str.replace(/([\&"<>])/g, function(str, item) { + return charMapping[item]; + }); } } \ No newline at end of file