openvsx
openvsx copied to clipboard
Web extension resources return incorrect MIME type
Contributes to #468 Use Apache Tika to detect mimetype
@amvanbaren I just found that mime types are listed in the [Content_Types].xml file inside the vsix :facepalm: So we just need to parse it and use the rules in there
<?xml version="1.0" encoding="utf-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension=".json" ContentType="application/json"/>
<Default Extension=".vsixmanifest" ContentType="text/xml"/>
<Default Extension=".png" ContentType="image/png"/>
<Default Extension=".md" ContentType="text/markdown"/>
<Default Extension=".js" ContentType="application/javascript"/>
<Default Extension=".map" ContentType="application/json"/>
<Default Extension=".txt" ContentType="text/plain"/>
<Default Extension=".woff2" ContentType="font/woff2"/>
<Default Extension=".html" ContentType="text/html"/>
<Default Extension=".css" ContentType="text/css"/>
</Types>
Some more info https://docs.microsoft.com/en-us/visualstudio/extensibility/the-structure-of-the-content-types-dot-xml-file?view=vs-2022#attribute-name-attribute-1
vsix files should be application/zip and all other file types application/octet-stream
I just found that mime types are listed in the [Content_Types].xml file inside the vsix 🤦 So we just need to parse it and use the rules in there.
Ok, I'll use that file to assign the right content type to a file resource. If the resource isn't listed then application/octet-stream is used.
vsix files should be application/zip and all other file types application/octet-stream
When I download a vsix file, then the content-type is application/vsix

When I download a vsix file, then the content-type is application/vsix
Then their docs are outdated :sweat_smile:
Need to test what happens when some files don't have file extension, e.g sometimes README files don't have the .md extension, maybe we should add some default rules by filename
From my testing, @jeanp413, if there is no extension present, it will not be in the [Content_Types].xml file. Do you think there could be cases in which serving everything with no extension with a text/plain would not work?
This is just concerning web extensions, correct? So there will be no binaries served, which are the only thing in my mind that don't usually have extensions.
cc @amvanbaren
Thanks for testing this, @filiptronicek, from the MS docs anything else should be application/octet-stream.
Looking at vsce source code they allow license without extension but then they add the file extension if it's missing when packaged so we won't have any issue :tada:
@amvanbaren I saw openvsx got finally deployed :tada:, can we merge this so it's shipped in next deployment :slightly_smiling_face: BTW, can you share until which commit got deployed?
can we merge this so it's shipped in next deployment 🙂
Yes, I'll rebase and complete this PR.
BTW, can you share until which commit got deployed?
Up until PR #517 is deployed. Production is 25 commits behind master.
@amvanbaren let's merge :pray:
@amvanbaren let's merge 🙏
@jeanp413 Has this been reviewed and tested?
I thought it was already approved :sweat_smile: , will take a look
This PR is missing a migration: https://github.com/eclipse/openvsx/issues/468#issuecomment-1323388969
@filiptronicek if you have some free time could you test this :pray: ?
Same priority as #468
Ok, I've fixed the PR. @filiptronicek Do you have time to test it?