Browse Source

avoid some false positives in png extraction

pull/54/head
coomdev 2 years ago
parent
commit
64925f2bee
  1. 5
      src/pngv3.ts

5
src/pngv3.ts

@ -61,7 +61,7 @@ const extractFromRawDeflate = (b: Buffer) => {
const hidden = new BitstreamWriter({ const hidden = new BitstreamWriter({
write(chunk) { write(chunk) {
for (const i of chunk) { for (const i of chunk) {
if (i) if (i >= 0x20 && i <= 128) // only printable ascii
chnks.push(i); chnks.push(i);
else else
throw "Finish"; throw "Finish";
@ -234,9 +234,8 @@ const extract = async (png: Buffer, doextract = true) => {
.toString() .toString()
.split(' ') .split(' ')
.map(e => { .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"; 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)}`; return `https://${rprefs[e[0]]}/${e.slice(1)}`;
}).join(' '); }).join(' ');
if (doextract) if (doextract)

Loading…
Cancel
Save