Rob--W / open-in-browser

A browser extension that offers the ability to open files directly in the browser instead of downloading them.
Other
83 stars 15 forks source link

.pkg with mislabeled as XML #36

Closed Rob--W closed 6 years ago

Rob--W commented 6 years ago

Someone provided a test case where the Open in Browser dialog mistakenly shows "XML" instead of "XAR archive".

Test case:

$ nc -p 8080
GET /example.xar
....

HTTP/1.1 200 OK
Content-Length: 2
Content-Type: application/vnd.apple.installer+xml

xx

The database does contain an entry https://github.com/Rob--W/open-in-browser/blob/a4a6e6c1e8a10f4a8f63d520f3026d018501e632/shared-mime-info/freedesktop.org.xml

  <mime-type type="application/x-xar">
    <comment>XAR archive</comment>
    <comment xml:lang="ca">arxiu XAR</comment>
    <comment xml:lang="cs">archiv XAR</comment>
    <comment xml:lang="da">XAR-arkiv</comment>
    <comment xml:lang="de">XAR-Archiv</comment>
    <comment xml:lang="en_GB">XAR archive</comment>
    <comment xml:lang="es">archivador XAR</comment>
    <comment xml:lang="eu">XAR artxiboa</comment>
    <comment xml:lang="fi">XAR-arkisto</comment>
    <comment xml:lang="fr">archive XAR</comment>
    <comment xml:lang="ga">cartlann XAR</comment>
    <comment xml:lang="he">ארכיון XAR</comment>
    <comment xml:lang="hr">XAR arhiva</comment>
    <comment xml:lang="hu">XAR archívum</comment>
    <comment xml:lang="id">Arsip XAR</comment>
    <comment xml:lang="it">Archivio XAR</comment>
    <comment xml:lang="kk">XAR архиві</comment>
    <comment xml:lang="ko">XAR 아카이브</comment>
    <comment xml:lang="oc">Archiu XAR</comment>
    <comment xml:lang="pl">Archiwum XAR</comment>
    <comment xml:lang="pt_BR">Arquivo XAR</comment>
    <comment xml:lang="ru">Архив XAR</comment>
    <comment xml:lang="sk">Archív XAR</comment>
    <comment xml:lang="sr">ИксАР архива</comment>
    <comment xml:lang="sv">XAR-arkiv</comment>
    <comment xml:lang="tr">XAR arşivi</comment>
    <comment xml:lang="uk">архів XAR</comment>
    <comment xml:lang="zh_CN">XAR 归档文件</comment>
    <comment xml:lang="zh_TW">XAR 封存檔</comment>
    <acronym>XAR</acronym>
    <expanded-acronym>eXtensible ARchive</expanded-acronym>
    <generic-icon name="package-x-generic"/>
    <magic priority="60">
      <match value="0x78617221" type="big32" offset="0"/>
    </magic>
    <glob pattern="*.xar"/>

    <glob pattern="*.pkg"/>
  </mime-type>

However the generated database does not: https://github.com/Rob--W/open-in-browser/blob/a4a6e6c1e8a10f4a8f63d520f3026d018501e632/extension/mime-metadata.js

Two things to check:

  1. Why does the generated database not contain a listing for .pkg?
  2. The server-provided MIME type is unknown. If the .pkg extensions is added to the database, will the extension recognize it or does the server-supplied MIME take precedence? If so, perhaps we should change the labeling heuristic to not label data as XML even if the server-supplied MIME contains +xml when the file extension maps to a non-XML type.