Tika mimetypes: make SVG magic more tolerant to doctype and comments

Detected by qthttpserver's unittests

Change-Id: I6d60ec232ceb5474f24f22ad822e55a9f2444fae
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit c612a82bbaa0411ca54fbabd2ca1760f0c5e0645)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
David Faure 2024-07-19 11:03:09 +02:00 committed by Qt Cherry-pick Bot
parent eb9fd6dbd4
commit f60bef8768
2 changed files with 5 additions and 1 deletions

View File

@ -117,6 +117,10 @@ with open_input_file(inputfile) as f:
if 'value="0x' in line and 'type="string"' in line:
line = transform_hex_value(line)
# Need more tolerance in SVG magic
if '&lt;svg' in line and 'offset="0"' in line:
line = line.replace('offset="0"', 'offset="0:100"')
if '<mime-info xmlns' in line:
line += """
<!-- Qt additions START -->

View File

@ -6015,7 +6015,7 @@
<root-XML localName="svg" namespaceURI="http://www.w3.org/2000/svg"/>
<magic priority="50">
<!-- Version of 0x0001 is PSD -->
<match value="&lt;svg" type="string" offset="0">
<match value="&lt;svg" type="string" offset="0:100">
<match value="http://www.w3.org/2000/svg" type="string" offset="5:256"/>
</match>
</magic>