Fixed qrread not being properly sanitized

This commit is contained in:
TheEssem 2021-03-04 08:42:45 -06:00
parent e3b3bdc7b7
commit a8db0a1204

View file

@ -1,6 +1,7 @@
const jsqr = require("jsqr"); const jsqr = require("jsqr");
const fetch = require("node-fetch"); const fetch = require("node-fetch");
const sharp = require("sharp"); const sharp = require("sharp");
const { clean } = require("../utils/misc.js");
exports.run = async (message) => { exports.run = async (message) => {
const image = await require("../utils/imagedetect.js")(message); const image = await require("../utils/imagedetect.js")(message);
@ -10,7 +11,7 @@ exports.run = async (message) => {
const rawData = await sharp(data).ensureAlpha().raw().toBuffer({ resolveWithObject: true }); const rawData = await sharp(data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height); const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
if (!qrBuffer) return `${message.author.mention}, I couldn't find a QR code!`; if (!qrBuffer) return `${message.author.mention}, I couldn't find a QR code!`;
return `\`\`\`\n${qrBuffer.data}\n\`\`\``; return `\`\`\`\n${await clean(qrBuffer.data)}\n\`\`\``;
}; };
exports.category = 1; exports.category = 1;