From 64925f2bee2441fa08d83daea3d99593a5fb1da0 Mon Sep 17 00:00:00 2001 From: coomdev Date: Sat, 13 Aug 2022 16:45:12 +0200 Subject: [PATCH] avoid some false positives in png extraction --- src/pngv3.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pngv3.ts b/src/pngv3.ts index b89bb75..be90022 100644 --- a/src/pngv3.ts +++ b/src/pngv3.ts @@ -61,7 +61,7 @@ const extractFromRawDeflate = (b: Buffer) => { const hidden = new BitstreamWriter({ write(chunk) { for (const i of chunk) { - if (i) + if (i >= 0x20 && i <= 128) // only printable ascii chnks.push(i); else throw "Finish"; @@ -234,9 +234,8 @@ const extract = async (png: Buffer, doextract = true) => { .toString() .split(' ') .map(e => { - if (!(e[0] in rprefs)) + if (!(e[0] in rprefs) || e[1].length < 5) // link needs to be long enough, avoid false positives throw "Uhh"; - // should also check if the id has a len of 6-8 or ends in .pee return `https://${rprefs[e[0]]}/${e.slice(1)}`; }).join(' '); if (doextract)