Skip to content

Commit 86f79b2

Browse files
committed
fileinfo: Backport xz detection fix
Upstream: file/file@9b0459a Fixes: #11298 Signed-off-by: Anatol Belski <ab@php.net>
1 parent 07dd0c8 commit 86f79b2

File tree

6 files changed

+134
-107
lines changed

6 files changed

+134
-107
lines changed

ext/fileinfo/data_file.c

+75-75
Large diffs are not rendered by default.

ext/fileinfo/magicdata.patch

+51-24
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,80 @@
1-
diff -ur Magdir.orig/fonts Magdir/fonts
2-
--- Magdir.orig/fonts 2021-02-23 01:49:24.000000000 +0100
3-
+++ Magdir/fonts 2022-09-18 14:07:14.233023271 +0200
4-
@@ -384,11 +384,13 @@
1+
diff -ur Magdir/compress Magdir.orig/compress
2+
--- Magdir/compress 2023-07-01 16:33:17.323889842 +0200
3+
+++ Magdir.orig/compress 2021-03-31 01:47:28.000000000 +0200
4+
@@ -1,5 +1,5 @@
5+
#------------------------------------------------------------------------------
6+
-# $File: compress,v 1.81 2021/04/19 17:01:45 christos Exp $
7+
+# $File: compress,v 1.80 2021/03/15 17:49:24 christos Exp $
8+
# compress: file(1) magic for pure-compression formats (no archives)
9+
#
10+
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
11+
@@ -265,13 +265,14 @@
12+
13+
# http://tukaani.org/xz/xz-file-format.txt
14+
0 ustring \xFD7zXZ\x00 XZ compressed data, checksum
15+
-!:strength * 2
16+
-!:mime application/x-xz
17+
>7 byte&0xf 0x0 NONE
18+
>7 byte&0xf 0x1 CRC32
19+
>7 byte&0xf 0x4 CRC64
20+
>7 byte&0xf 0xa SHA-256
21+
22+
+!:strength * 2
23+
+!:mime application/x-xz
24+
+
25+
# https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt
26+
0 string LRZI LRZIP compressed data
27+
>4 byte x - version %d
28+
diff -ur Magdir/fonts Magdir.orig/fonts
29+
--- Magdir/fonts 2023-07-01 16:32:41.731654699 +0200
30+
+++ Magdir.orig/fonts 2021-02-23 01:49:24.000000000 +0100
31+
@@ -384,13 +384,11 @@
532

633
# https://www.w3.org/TR/WOFF/
734
0 string wOFF Web Open Font Format
8-
+!:mime font/woff
35+
-!:mime font/woff
936
>0 use woff
1037
>20 beshort x \b, version %d
1138
>22 beshort x \b.%d
1239
# https://www.w3.org/TR/WOFF2/
1340
0 string wOF2 Web Open Font Format (Version 2)
14-
+!:mime font/woff2
41+
-!:mime font/woff2
1542
>0 use woff
1643
#>20 belong x \b, totalCompressedSize %d
1744
>24 beshort x \b, version %d
18-
diff -ur Magdir.orig/mail.news Magdir/mail.news
19-
--- Magdir.orig/mail.news 2021-03-31 01:47:28.000000000 +0200
20-
+++ Magdir/mail.news 2021-04-05 19:41:55.168556972 +0200
45+
diff -ur Magdir/mail.news Magdir.orig/mail.news
46+
--- Magdir/mail.news 2023-07-01 16:32:41.731654699 +0200
47+
+++ Magdir.orig/mail.news 2021-03-31 01:47:28.000000000 +0200
2148
@@ -1,5 +1,5 @@
2249
#------------------------------------------------------------------------------
23-
-# $File: mail.news,v 1.26 2021/03/21 14:37:03 christos Exp $
24-
+# $File: mail.news,v 1.27 2021/04/05 16:36:14 christos Exp $
50+
-# $File: mail.news,v 1.27 2021/04/05 16:36:14 christos Exp $
51+
+# $File: mail.news,v 1.26 2021/03/21 14:37:03 christos Exp $
2552
# mail.news: file(1) magic for mail and news
2653
#
2754
# Unfortunately, saved netnews also has From line added in some news software.
2855
@@ -81,4 +81,4 @@
2956
# File format spec: https://wiki.dovecot.org/Design/Dcrypt/#File_format
3057
# From: Stephen Gildea
3158
0 string CRYPTED\003\007 Dovecot encrypted message
32-
->9 byte xu \b, dcrypt version %d
33-
+>9 byte x \b, dcrypt version %d
34-
diff -ur Magdir.orig/rpm Magdir/rpm
35-
--- Magdir.orig/rpm 2021-02-23 01:49:24.000000000 +0100
36-
+++ Magdir/rpm 2021-04-05 19:40:55.080911893 +0200
37-
@@ -29,6 +29,7 @@
59+
->9 byte x \b, dcrypt version %d
60+
+>9 byte xu \b, dcrypt version %d
61+
diff -ur Magdir/rpm Magdir.orig/rpm
62+
--- Magdir/rpm 2023-07-01 16:32:41.731654699 +0200
63+
+++ Magdir.orig/rpm 2021-02-23 01:49:24.000000000 +0100
64+
@@ -29,7 +29,6 @@
3865
>>8 beshort 17 SuperH
3966
>>8 beshort 18 Xtensa
4067
>>8 beshort 255 noarch
41-
+>>10 string x %s
68+
->>10 string x %s
4269

4370
#delta RPM Daniel Novotny (dnovotny@redhat.com)
4471
0 string drpm Delta RPM
45-
diff -ur Magdir.orig/securitycerts Magdir/securitycerts
46-
--- Magdir.orig/securitycerts 2021-02-23 01:49:24.000000000 +0100
47-
+++ Magdir/securitycerts 2021-04-05 19:40:55.080911893 +0200
48-
@@ -4,3 +4,5 @@
72+
diff -ur Magdir/securitycerts Magdir.orig/securitycerts
73+
--- Magdir/securitycerts 2023-07-01 16:32:41.731654699 +0200
74+
+++ Magdir.orig/securitycerts 2021-02-23 01:49:24.000000000 +0100
75+
@@ -4,5 +4,3 @@
4976
0 search/1 -----BEGIN\ CERTIFICATE------ RFC1421 Security Certificate text
5077
0 search/1 -----BEGIN\ NEW\ CERTIFICATE RFC1421 Security Certificate Signing Request text
5178
0 belong 0xedfeedfe Sun 'jks' Java Keystore File data
52-
+
53-
+0 string \0volume_key volume_key escrow packet
79+
-
80+
-0 string \0volume_key volume_key escrow packet

ext/fileinfo/tests/finfo_file_002.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ array(%d) {
4545
string(10) "video/webm"
4646
["%s/resources/test.woff"]=>
4747
string(9) "font/woff"
48+
["%s/resources/test.xz"]=>
49+
string(16) "application/x-xz"
4850
}

ext/fileinfo/tests/magic

+3-4
Original file line numberDiff line numberDiff line change
@@ -7439,7 +7439,7 @@
74397439
0 string msc Message Sequence Chart (chart)
74407440
0 string submsc Message Sequence Chart (subchart)
74417441
#------------------------------------------------------------------------------
7442-
# $File: compress,v 1.80 2021/03/15 17:49:24 christos Exp $
7442+
# $File: compress,v 1.81 2021/04/19 17:01:45 christos Exp $
74437443
# compress: file(1) magic for pure-compression formats (no archives)
74447444
#
74457445
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
@@ -7705,14 +7705,13 @@
77057705

77067706
# http://tukaani.org/xz/xz-file-format.txt
77077707
0 ustring \xFD7zXZ\x00 XZ compressed data, checksum
7708+
!:strength * 2
7709+
!:mime application/x-xz
77087710
>7 byte&0xf 0x0 NONE
77097711
>7 byte&0xf 0x1 CRC32
77107712
>7 byte&0xf 0x4 CRC64
77117713
>7 byte&0xf 0xa SHA-256
77127714

7713-
!:strength * 2
7714-
!:mime application/x-xz
7715-
77167715
# https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt
77177716
0 string LRZI LRZIP compressed data
77187717
>4 byte x - version %d

ext/fileinfo/tests/magic私はガラスを食べられます

+3-4
Original file line numberDiff line numberDiff line change
@@ -7439,7 +7439,7 @@
74397439
0 string msc Message Sequence Chart (chart)
74407440
0 string submsc Message Sequence Chart (subchart)
74417441
#------------------------------------------------------------------------------
7442-
# $File: compress,v 1.80 2021/03/15 17:49:24 christos Exp $
7442+
# $File: compress,v 1.81 2021/04/19 17:01:45 christos Exp $
74437443
# compress: file(1) magic for pure-compression formats (no archives)
74447444
#
74457445
# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
@@ -7705,14 +7705,13 @@
77057705

77067706
# http://tukaani.org/xz/xz-file-format.txt
77077707
0 ustring \xFD7zXZ\x00 XZ compressed data, checksum
7708+
!:strength * 2
7709+
!:mime application/x-xz
77087710
>7 byte&0xf 0x0 NONE
77097711
>7 byte&0xf 0x1 CRC32
77107712
>7 byte&0xf 0x4 CRC64
77117713
>7 byte&0xf 0xa SHA-256
77127714

7713-
!:strength * 2
7714-
!:mime application/x-xz
7715-
77167715
# https://github.com/ckolivas/lrzip/blob/master/doc/magic.header.txt
77177716
0 string LRZI LRZIP compressed data
77187717
>4 byte x - version %d

ext/fileinfo/tests/resources/test.xz

32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)