From b5df32dc4cbd6b77671371384944c37225310af8 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 14 Feb 2022 12:19:01 +0000 Subject: text/x-qml: Lower match priority to avoid conflicts with Python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GLib takes priorities >= 80 to mean a short-circuit to a magic match, overriding any conflicting matching globs. More generally, high priority magic should only be used if it’s really unlikely that the magic will match anything except the given MIME type. That’s evidently not true here. Some Python files which import Qt modules can look like valid QML files, matching the magic but not the glob. Lower the priority of the magic so that it doesn’t trigger the short-circuit code in GLib. This means the name match is guessed as the right one instead of the magic match. See https://gitlab.gnome.org/GNOME/glib/-/blob/6ee71750a532d8de5eaed5cf12e8718738ddd5c6/gio/gcontenttype.c#L840 and https://gitlab.gnome.org/GNOME/glib/-/issues/2599. Tested with `XDG_DATA_DIRS=$buildroot/share gio info ./not-qml.py`. Signed-off-by: Philip Withnall Helps: #84 --- data/freedesktop.org.xml.in | 2 +- tests/mime-detection/list | 2 ++ tests/mime-detection/not-qml.py | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/mime-detection/not-qml.py diff --git a/data/freedesktop.org.xml.in b/data/freedesktop.org.xml.in index 4840c3ea..367483a7 100644 --- a/data/freedesktop.org.xml.in +++ b/data/freedesktop.org.xml.in @@ -2019,7 +2019,7 @@ command to generate the output files. Qt Markup Language file - + diff --git a/tests/mime-detection/list b/tests/mime-detection/list index 74257889..77c5d79a 100644 --- a/tests/mime-detection/list +++ b/tests/mime-detection/list @@ -412,6 +412,8 @@ test.py3 text/x-python3 test.pyi text/x-python3 ox # PySide pyside.py text/x-python +# https://ru.stackoverflow.com/questions/1381587/%d0%9d%d0%b5%d0%bf%d1%80%d0%b0%d0%b2%d0%b8%d0%bb%d1%8c%d0%bd%d0%be-%d1%80%d0%b0%d1%81%d0%bf%d0%be%d0%b7%d0%bd%d0%b0%d1%91%d1%82-py-%d1%84%d0%b0%d0%b9%d0%bb/1381685 +not-qml.py text/x-python ox # SageMath example_mime.sage text/x-sagemath oxo # Perl diff --git a/tests/mime-detection/not-qml.py b/tests/mime-detection/not-qml.py new file mode 100644 index 00000000..9e78f029 --- /dev/null +++ b/tests/mime-detection/not-qml.py @@ -0,0 +1,3 @@ +from PyQt5 import QtCore + +# { -- cgit v1.2.1