Repository navigation
Commit c78f551
committed
Improve binary file check to better handle PDFs
PDF files can have a very long text header before the first NUL byte
The check now reads the first 2KB rather than 128 bytes, and uses the
built-in index() function rather than looping which is very fast. That
still didn't catch all PDFs, even increasing it to 8000 bytes like git
diff didn't catch all PDFs, so also check for %PDF- signature in file.
The increased number of bytes to check remains even with the %PDF-
signature check because it costs very little (page size is min 4KB),
and will potentially catch other binary files with long text headers.1 parent 77c0bdd commit c78f551
1 file changed
Lines changed: 17 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
15 | 24 | | |
16 | 25 | | |
17 | 26 | | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| 30 | + | |
| 31 | + | |
21 | 32 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
26 | 38 | | |
27 | 39 | | |
28 | 40 | | |
| |||
0 commit comments