Bug 474190

Summary: text files starting with PACKAGE* get the mime type application/x-pak instead of text/plain
Product: [I don't know] kde Reporter: Werner Sembach [TUXEDO] <wse>
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED UPSTREAM    
Severity: normal CC: nate, tagwerk19
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Werner Sembach [TUXEDO] 2023-09-05 15:21:11 UTC
SUMMARY
Any plaintext file that starts with PACKAGE* and doesn't have a filename ending associated with a mime type, gets the mime type application/x-pak. This happens for example fore dkms.conf file that don't have licensing information preceding and therefore start with PACKAGE_NAME=<some_name>

STEPS TO REPRODUCE
echo "PACKAGEloremipsum" > foo

OBSERVED RESULT
foo has the mime type application/x-pak

EXPECTED RESULT
foo has the mime type text/plain

SOFTWARE/OS VERSIONS
Linux: 6.2.0-10018-tuxedo
(available in About System)
KDE Plasma Version: 5.27.7
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.10
Comment 1 Nate Graham 2023-09-05 19:30:26 UTC
This would be a bug in the detection code upstream in shared-mime-info; please report it at https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues. Thanks!
Comment 2 Werner Sembach [TUXEDO] 2023-09-20 12:51:22 UTC
(In reply to Nate Graham from comment #1)
> This would be a bug in the detection code upstream in shared-mime-info;
> please report it at
> https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues. Thanks!

thanks for the redirection
Comment 3 tagwerk19 2023-09-20 14:50:27 UTC
(In reply to Werner Sembach [TUXEDO] from comment #0)
> STEPS TO REPRODUCE
> echo "PACKAGEloremipsum" > foo
> 
> OBSERVED RESULT
> foo has the mime type application/x-pak
That comes from the following entry in:

    /usr/share/mime/packages/freedesktop.org.xml

   <mime-type type="application/x-pak">
     <comment>PAK archive</comment>
      ...
     <comment xml:lang="en_GB">PAK archive</comment>
      ...
     <generic-icon name="package-x-generic"/>
     <magic priority="80">
       <match offset="0" type="string" value="PACK"/>
     </magic>
     <glob pattern="*.pak"/>
   </mime-type>

Looks like the "PAK Archive" format was something in DOS back in the 1990's. Can give you a German Wiki article (seemingly no English equivalent):

    https://de.wikipedia.org/wiki/PAK_(Dateiformat)
Comment 4 Werner Sembach [TUXEDO] 2023-09-20 16:12:47 UTC
(In reply to tagwerk19 from comment #3)
> (In reply to Werner Sembach [TUXEDO] from comment #0)
> > STEPS TO REPRODUCE
> > echo "PACKAGEloremipsum" > foo
> > 
> > OBSERVED RESULT
> > foo has the mime type application/x-pak
> That comes from the following entry in:
> 
>     /usr/share/mime/packages/freedesktop.org.xml
> 
>    <mime-type type="application/x-pak">
>      <comment>PAK archive</comment>
>       ...
>      <comment xml:lang="en_GB">PAK archive</comment>
>       ...
>      <generic-icon name="package-x-generic"/>
>      <magic priority="80">
>        <match offset="0" type="string" value="PACK"/>
>      </magic>
>      <glob pattern="*.pak"/>
>    </mime-type>
> 
> Looks like the "PAK Archive" format was something in DOS back in the 1990's.
> Can give you a German Wiki article (seemingly no English equivalent):
> 
>     https://de.wikipedia.org/wiki/PAK_(Dateiformat)

A propriatary ancient format with a far to generic magic value :/

I guess if someone sees this and still has such a file lying around let me know, maybe there are additional magic values that can be used.
Comment 5 Werner Sembach [TUXEDO] 2023-09-20 16:14:31 UTC
Bug is opened btw on freedesktop side: https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/210