Skip to content

Commit bd24c56

Browse files
committedSep 30, 2023
fileinfo: Backport svg detection patch
This patch is a port of 1f5bea3 and adds a port for 5.43 based branches. The related test is unchanged. Signed-off-by: Anatol Belski <ab@php.net>
1 parent ec2ef64 commit bd24c56

File tree

6 files changed

+191
-152
lines changed

6 files changed

+191
-152
lines changed
 

‎ext/fileinfo/data_file.c

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

‎ext/fileinfo/magicdata.patch

+23
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,26 @@ diff -ur Magdir.orig/securitycerts Magdir/securitycerts
5151
0 belong 0xedfeedfe Sun 'jks' Java Keystore File data
5252
+
5353
+0 string \0volume_key volume_key escrow packet
54+
diff --git a/magic/Magdir/sgml b/magic/Magdir/sgml
55+
--- Magdir.orig/sgml
56+
+++ Magdir/sgml
57+
@@ -1,16 +1,17 @@
58+
59+
#------------------------------------------------------------------------------
60+
-# $File: sgml,v 1.48 2023/01/18 16:10:21 christos Exp $
61+
+# $File: sgml,v 1.49 2023/08/05 14:34:47 christos Exp $
62+
# Type: SVG Vectorial Graphics
63+
# From: Noel Torres <tecnico@ejerciciosresueltos.com>
64+
-0 string \<?xml\ version=
65+
+0 string/bt \<?xml\ version=
66+
>14 regex ['"\ \t]*[0-9.]+['"\ \t]*
67+
>>19 search/4096 \<svg SVG Scalable Vector Graphics image
68+
+!:strength +50
69+
!:mime image/svg+xml
70+
!:ext svg
71+
>>19 search/4096 \<gnc-v2 GnuCash file
72+
!:mime application/x-gnucash
73+
-0 string \<svg SVG Scalable Vector Graphics image
74+
+0 string/bt \<svg SVG Scalable Vector Graphics image
75+
!:mime image/svg+xml
76+
!:ext svg

‎ext/fileinfo/tests/bug-gh11891.phpt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug GH-11891: fileinfo returns text/xml for some svg files
3+
--EXTENSIONS--
4+
fileinfo
5+
--FILE--
6+
<?php
7+
var_dump(
8+
(new \finfo(\FILEINFO_MIME_TYPE))->file(
9+
__DIR__ . '/bug-gh11891.svg',
10+
),
11+
);
12+
?>
13+
--EXPECT--
14+
string(13) "image/svg+xml"

‎ext/fileinfo/tests/bug-gh11891.svg

686 Bytes
Loading

‎ext/fileinfo/tests/magic

+3-2
Original file line numberDiff line numberDiff line change
@@ -35130,14 +35130,15 @@
3513035130
# $File: sgml,v 1.46 2022/08/16 11:16:39 christos Exp $
3513135131
# Type: SVG Vectorial Graphics
3513235132
# From: Noel Torres <tecnico@ejerciciosresueltos.com>
35133-
0 string \<?xml\ version=
35133+
0 string/bt \<?xml\ version=
3513435134
>14 regex ['"\ \t]*[0-9.]+['"\ \t]*
3513535135
>>19 search/4096 \<svg SVG Scalable Vector Graphics image
35136+
!:strength +50
3513635137
!:mime image/svg+xml
3513735138
!:ext svg
3513835139
>>19 search/4096 \<gnc-v2 GnuCash file
3513935140
!:mime application/x-gnucash
35140-
0 string \<svg SVG Scalable Vector Graphics image
35141+
0 string/bt \<svg SVG Scalable Vector Graphics image
3514135142
!:mime image/svg+xml
3514235143
!:ext svg
3514335144

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -35130,14 +35130,15 @@
3513035130
# $File: sgml,v 1.46 2022/08/16 11:16:39 christos Exp $
3513135131
# Type: SVG Vectorial Graphics
3513235132
# From: Noel Torres <tecnico@ejerciciosresueltos.com>
35133-
0 string \<?xml\ version=
35133+
0 string/bt \<?xml\ version=
3513435134
>14 regex ['"\ \t]*[0-9.]+['"\ \t]*
3513535135
>>19 search/4096 \<svg SVG Scalable Vector Graphics image
35136+
!:strength +50
3513635137
!:mime image/svg+xml
3513735138
!:ext svg
3513835139
>>19 search/4096 \<gnc-v2 GnuCash file
3513935140
!:mime application/x-gnucash
35140-
0 string \<svg SVG Scalable Vector Graphics image
35141+
0 string/bt \<svg SVG Scalable Vector Graphics image
3514135142
!:mime image/svg+xml
3514235143
!:ext svg
3514335144

0 commit comments

Comments
 (0)