@@ -30,13 +30,14 @@ function detect(bShowType,bShowVersion,bShowOptions) {
30
30
var sus = 0, cmin = File.read_uint16(3), cmlen = File.read_uint16(5), cmsz = File.read_uint8(7),
31
31
x0 = File.read_uint16(8), y0 = File.read_uint16(0xA),
32
32
w = File.read_uint16(0xC), h = File.read_uint16(0xE), attr = File.read_uint8(0x11);
33
- if(!w || !h || w > 4096 || h > 2048 || x0 > 1600 || y0 > 1200 || cmsz > 32) return false;
33
+ if(!w || !h || w > 4096 || h > 2048 || x0 > 1600 || y0 > 1200 || cmsz > 32 || (attr&0xC0) ) return false;
34
34
// suspiciousness is probably the only way to filter out all the FPs, so let's measure that
35
35
if(x0) sus++; if(y0) sus++; if(w < 4) sus++; if(h < 4) sus++; if(w > 1600) sus++; if(h > 1200) sus++;
36
+ if(attr&0x10) sus++; // that's right-to-left
36
37
if(!cmsz && cmlen) return false;
37
38
if(cmt == 1 && (it == 2 || it == 10)) sus++; //shouldn't have colour maps with True-color
38
39
if(cmsz < 15 || isWithin(cmsz,17,23) || isWithin(cmsz,25,31)) sus++; if(cmlen > 256) sus++; if(cmin) sus++;
39
- if(it == 0 ) { if(cmin) sus++; if(cmlen) sus++; if(cmsz) sus++ }
40
+ if(it == 2 || it == 10 ) { if(cmin) sus++; if(cmlen) sus++; if(cmsz) sus++ }
40
41
if(it != 1 && it != 9 && it != 32 && it != 33) depth = bpp <= 8 ? 8 : (bpp <= 16 ? 5 : 8);
41
42
else depth = cmsz <= 8 ? 8 : (cmsz <= 16 ? 5 : 8);
42
43
var col = 1 << depth;
@@ -141,9 +142,7 @@ function detect(bShowType,bShowVersion,bShowOptions) {
141
142
if(co != "rle" || File.isDeepScan()) sOption(outSz(p),"sz:")
142
143
}
143
144
if(bad != "") sVersion += "/malformed"+bad;
144
-
145
145
bDetected = true;
146
- return result(bShowType,bShowVersion,bShowOptions);
147
-
148
- return result();
146
+
147
+ return result();
149
148
}
0 commit comments