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)

See Also:
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

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.

Note You need to log in before you can comment on or make changes to this bug.