Bug 384275 - Some text files incorrectly identified as 'MATLAB script/function'
Summary: Some text files incorrectly identified as 'MATLAB script/function'
Status: RESOLVED UPSTREAM
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 17.08.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-02 06:05 UTC by tguen
Modified: 2017-09-05 07:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
dolphin recogizes as MATLAB (9.12 KB, text/x-matlab)
2017-09-02 06:05 UTC, tguen
Details
dolphin recogizes as MATLAB (21.73 KB, text/plain)
2017-09-02 06:06 UTC, tguen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tguen 2017-09-02 06:05:54 UTC
Created attachment 107644 [details]
dolphin recogizes as MATLAB

Many text files on my system are identified as 'MATLAB script/function' including /etc/nanorc, /etc/pacman.d/mirrorlist.pacnew, and a markdown file that uses the .md extension. In the last case, I don't see why dolphin should try to guess what type of file it is if it uses a recognized file extension. Is there any reason why the extension is not the primary means of identifying file types?
Comment 1 tguen 2017-09-02 06:06:41 UTC
Created attachment 107645 [details]
dolphin recogizes as MATLAB
Comment 2 Elvis Angelaccio 2017-09-02 08:43:05 UTC
(In reply to rasq37 from comment #0)
> Created attachment 107644 [details]
> dolphin recogizes as MATLAB
> 
> Many text files on my system are identified as 'MATLAB script/function'
> including /etc/nanorc, /etc/pacman.d/mirrorlist.pacnew

This happens because of this rule in the shared-mime-info database:

    <magic priority="10">
      <match type="string" value="##" offset="0"/>
    </magic>

So any text file whose first line starts with two or more '#' will be identified as matlab script (unless an higher priority rule says otherwise).

> and a markdown file that uses the .md extension.

Can't reproduce this, the .md extension should rule out Matlab. Can you attach a test file?

> In the last case, I don't see why dolphin
> should try to guess what type of file it is if it uses a recognized file
> extension. Is there any reason why the extension is not the primary means of
> identifying file types?

In general, extensions may be missing or wrong.
Comment 3 tguen 2017-09-04 23:50:08 UTC
The markdown file was the same issue; it started with '##'. 

> (unless an higher priority rule says otherwise)

I tried changing that rule's priority, but it didn't seem to have any effect so I just removed it instead. Is is possible that Dolphin isn't reading the priorities correctly? Could this explain the fact that I have to remove the *.iso pattern from everything but application/x-cd-image to prevent Dolphin from listing half of my iso files as plain text?

Regardless, this rule seems like a bad idea. Any text file can start with ##, that shouldn't identify it as MATLAB. I think this is still deserving of a bug report, but does it have anything to do with Dolphin, or any other KDE project? If not, where should it go?
Comment 4 Elvis Angelaccio 2017-09-05 07:58:45 UTC
(In reply to rasq37 from comment #3)
> The markdown file was the same issue; it started with '##'. 
> 
> > (unless an higher priority rule says otherwise)
> 
> I tried changing that rule's priority, but it didn't seem to have any effect
> so I just removed it instead. Is is possible that Dolphin isn't reading the
> priorities correctly? Could this explain the fact that I have to remove the
> *.iso pattern from everything but application/x-cd-image to prevent Dolphin
> from listing half of my iso files as plain text?

That's https://bugs.freedesktop.org/show_bug.cgi?id=80877

> 
> Regardless, this rule seems like a bad idea. Any text file can start with
> ##, that shouldn't identify it as MATLAB. I think this is still deserving of
> a bug report, but does it have anything to do with Dolphin, or any other KDE
> project? If not, where should it go?

Here: https://bugs.freedesktop.org/ (against the shared-mime-info product)