Registered Member
|
Greetings.
Got a problem with Dolphin that has been bugging the **** out of me. I got various text only files. For instance "textfile.tpl". I tell Dolphin/KDE to open these files with kate. No problems. But then, something weird happens: Whenever this tpl-file (or other text-only files) happen to contain a beginning of a html document. (<html>, <head>, <meta>, <title> ) it changes its association to "html-document" and will open in my default web browser instead. Keep in mind that I never renamed the file. It can be named pretty much anything, and wiull still be seen as a html-document for as long it contain these html-tags My question: How do I force Dolphin to ignore the content of the file, and look ONLY at the filename ending? To be honest, I don't want Dolphin to care about files contents in any case... at all. So turning that "feature" off would be the best. How do I do that? |
Manager
|
|
Registered Member
|
Well. Kinda works, but... But it doesn't solve my problem where any kind of file, no matter file extension, will be treated as a html-document if it contains the mentioned tags. With the suggested method, I have to include all possible extensions I don't want to be treated as html-documents. I'll use this as a temporary makeshift solution for now. EDIT: No. It didn't work. Despite this, the files that contain the mentioned html tags are still treated as html-documents. If I try to force a change through "Open With" menu option, it'll change all html-documents, and will even change "default browser". |
Administrator
|
This is due to a system called "magic bytes" - which is the primary mechanism used to determine the type of a file. I'm not sure how hard it is to make extensions preferred however, but it is done for *.odt files so it should be possible.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
Yes. I know these magic bytes, but they're usually at the beginning of the file, and often 2 bytes long. (Sometimes longer, but the initial detection is done on the two first bytes) Hashbangs are a good example of text/script files that utilises these magic bytes ( #! ) The problem here is different. It doesn't matter where these html tags sits. They can be anywhere in the file, and still trigger "I'm a html document" event. If I remove these html-tags (<html>, <head>, <meta>, <title>), the file falls back to its "original" association based on the file name extension. There is something behind the scenes that I cannot figure out. |
Manager
|
text and therefore html files don't use magic bytes (numbers) so it's a different process doing the association
maybe this will help (maybe not) from /etc/htdig/HtFileType-magic.mime note: I replaced tabs with "@"s for readability
|
Administrator
|
From what I understand, the freedesktop.org mime association system matches magic strings using a number of different rules. It appears that the HTML rule covers the whole file - which is why you are observing this behaviour.
To confirm this is the case, please run "file --mime-type <filename>" against one of the *.tpl files in question.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered Member
|
These are the files: "index.tpl"
"test.tpl"
Here's the results:
It is confirmed. If the file contains the earlier mentioned html-tags it will forcibly be treated as a html-document, despite that I have other/manual associations set up. I wish that this detection only worked on files that has no other associations. Or at least a possibility to change association precedence. Perhaps even a possibility to turn all those content-detections off. |
Registered Member
|
htdig ? I don't have that package installed (Arch Linux: https://www.archlinux.org/packages/extr ... dig/files/) This is my ~/.local/share/applications/mimeapps.list :
I also have a separate association set up for *.tpl : ~/.local/share/mime/packages/text-tpl.xml :
What other mimelists could override my own local settings? (Some more information on Arch Linux "Default Applications": https://wiki.archlinux.org/index.php/De ... plications ) |
Administrator
|
The magic files are checked first from what I am aware - as magic recognition is seen as more reliable than file extensions.
The following sequences will trigger recognition as a HTML file (at least on my system), subject to certain restrictions such as being at the start of a new line:
The only special detail I could see with *.odt files was the presence of the following directive:
If you edit your text/tpl association, to make it a subclass of text/html, then it will probably override the text/html association.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]