Skip to content

Commit

Permalink
fileinfo: Backport svg detection patch
Browse files Browse the repository at this point in the history
  • Loading branch information
usarise authored and weltling committed Sep 30, 2023
1 parent 643c4ba commit 1f5bea3
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 150 deletions.
292 changes: 146 additions & 146 deletions ext/fileinfo/data_file.c

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions ext/fileinfo/magicdata.patch
Expand Up @@ -78,3 +78,23 @@ diff -ur Magdir/securitycerts Magdir.orig/securitycerts
0 belong 0xedfeedfe Sun 'jks' Java Keystore File data
-
-0 string \0volume_key volume_key escrow packet
diff -ur Magdir/sgml Magdir.orig/sgml
--- Magdir/sgml 2023-08-09 16:00:55.807784619 +0000
+++ Magdir.orig/sgml 2021-02-23 00:49:24.000000000 +0000
@@ -3,14 +3,13 @@
# $File: sgml,v 1.42 2020/12/12 20:01:47 christos Exp $
# Type: SVG Vectorial Graphics
# From: Noel Torres <tecnico@ejerciciosresueltos.com>
-0 string/bt \<?xml\ version=
+0 string \<?xml\ version=
>14 regex ['"\ \t]*[0-9.]+['"\ \t]*
>>19 search/4096 \<svg SVG Scalable Vector Graphics image
-!:strength +50
!:mime image/svg+xml
>>19 search/4096 \<gnc-v2 GnuCash file
!:mime application/x-gnucash
-0 string/bt \<svg SVG Scalable Vector Graphics image
+0 string \<svg SVG Scalable Vector Graphics image
!:mime image/svg+xml

# Sitemap file
14 changes: 14 additions & 0 deletions ext/fileinfo/tests/bug-gh11891.phpt
@@ -0,0 +1,14 @@
--TEST--
Bug GH-11891: fileinfo returns text/xml for some svg files
--EXTENSIONS--
fileinfo
--FILE--
<?php
var_dump(
(new \finfo(\FILEINFO_MIME_TYPE))->file(
__DIR__ . '/bug-gh11891.svg',
),
);
?>
--EXPECT--
string(13) "image/svg+xml"
Binary file added ext/fileinfo/tests/bug-gh11891.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions ext/fileinfo/tests/magic
Expand Up @@ -30298,13 +30298,14 @@
# $File: sgml,v 1.42 2020/12/12 20:01:47 christos Exp $
# Type: SVG Vectorial Graphics
# From: Noel Torres <tecnico@ejerciciosresueltos.com>
0 string \<?xml\ version=
0 string/bt \<?xml\ version=
>14 regex ['"\ \t]*[0-9.]+['"\ \t]*
>>19 search/4096 \<svg SVG Scalable Vector Graphics image
!:strength +50
!:mime image/svg+xml
>>19 search/4096 \<gnc-v2 GnuCash file
!:mime application/x-gnucash
0 string \<svg SVG Scalable Vector Graphics image
0 string/bt \<svg SVG Scalable Vector Graphics image
!:mime image/svg+xml

# Sitemap file
Expand Down
5 changes: 3 additions & 2 deletions ext/fileinfo/tests/magic私はガラスを食べられます
Expand Up @@ -30298,13 +30298,14 @@
# $File: sgml,v 1.42 2020/12/12 20:01:47 christos Exp $
# Type: SVG Vectorial Graphics
# From: Noel Torres <tecnico@ejerciciosresueltos.com>
0 string \<?xml\ version=
0 string/bt \<?xml\ version=
>14 regex ['"\ \t]*[0-9.]+['"\ \t]*
>>19 search/4096 \<svg SVG Scalable Vector Graphics image
!:strength +50
!:mime image/svg+xml
>>19 search/4096 \<gnc-v2 GnuCash file
!:mime application/x-gnucash
0 string \<svg SVG Scalable Vector Graphics image
0 string/bt \<svg SVG Scalable Vector Graphics image
!:mime image/svg+xml

# Sitemap file
Expand Down

0 comments on commit 1f5bea3

Please sign in to comment.