Bug 54804 - ZipPackage uses Default instead of Override for files with no extension in [Content_Types].xml
Summary: ZipPackage uses Default instead of Override for files with no extension in [C...
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: WindowsBase (show other bugs)
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Future Release
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-04-07 21:06 UTC by Jonathan Pryor
Modified: 2017-10-06 12:16 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
bxc-45804.zip (1.95 KB, application/zip)
2017-04-07 21:14 UTC, Jonathan Pryor
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 54804 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Jonathan Pryor 2017-04-07 21:06:23 UTC
It's like Bug #1463, but the opposite!

Take the ZipPackage sample, fix it up so it compiles, then change `documentPath` so that it refers to a file *without* an extension.

https://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage(v=vs.110).aspx

Generate the package, then unzip the package. `[Content_Types].xml` contains a `<Default/>` element with an "empty" `Extension` attribute:

> <Default ContentType="text/xml" Extension="" /

This is counter to the Content Types Stream Schema, §D.1:

http://www.ecma-international.org/publications/standards/Ecma-376.htm
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-376,%20Fourth%20Edition,%20Part%202%20-%20Open%20Packaging%20Conventions.zip

       <xs:element name="Default" type="CT_Default"/>
    <xs:complexType name="CT_Default">
       <xs:attribute name="Extension" type="ST_Extension" use="required"/>
    <xs:simpleType name="ST_Extension">
       <xs:restriction base="xs:string">
       <xs:pattern value=" ([!$&amp;'\(\)\*\+,:=]|(%[0-9a-fA-F][0-9a-fA-F])|[:@]|[a-zA-Z0-9\-_~])+"/>

Note that the ST_Extension pattern requires a non-empty string.

If a part without an extension is encountered, it must instead use <Override/>.
Comment 1 Jonathan Pryor 2017-04-07 21:14:54 UTC
Created attachment 21339 [details]
bxc-45804.zip
Comment 2 Jonathan Pryor 2017-04-07 21:18:33 UTC
To repro:

  curl -o bxc-45804.zip https://bugzilla.xamarin.com/attachment.cgi?id=21339
  unzip bxc-45804.zip
  cd bxc-45804.zip
  make all run

Resulting output, nicely formatted:

> <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
>   <Default ContentType="text/xml" Extension="" />
>   <Default ContentType="application/vnd.openxmlformats-package.relationships+xml" Extension="rels" />
>   <Default ContentType="image/jpeg" Extension="jpg" />
> </Types>

Note the `<Default/>` element with an empty `//Default/@Extension` value.

Expected output: <Override/> should be used for files without an extension:

> <Override PartName="/Document" ContentType="text/xml" />
Comment 3 Jonathan Pryor 2017-04-07 21:20:59 UTC
I ran into this issue when trying to create a .vsix file for xamarin-android. Some files within the .vsix file have no extension -- running into this bug -- and as a result, Visual Studio refuses to install the package:

> Installation Failed
> The file is not a valid VSIX package.

The install log says:

> System.Xml.XmlException: ‘Default’ tag requires a nonempty ‘Extension’ attribute. Line 1, position 618.