Skip to content

One illegal uri in Relationship will destroy the document parsing #715

Closed
@lindexi

Description

@lindexi

Description

The PPTX document that include an illegal uri in Relationship will make the System.IO.Packaging.InternalRelationshipCollection.ProcessRelationshipAttributes throw an exception to OpenXmlPart.Load.

And the OpenXmlPart.Load can not catch the exception and it will break the PresentationDocument.Open.

Information

  • .NET Target: All
  • DocumentFormat.OpenXml Version: 2.10.1

Repro

var document = PresentationDocument.Open("hyperlink.pptx", isEditable: false, openSettings)

Here is the hyperlink.pptx file : https://1drv.ms/p/s!AiKjiQqRWKThlv5zkY4HoRvvJ3Ppdg?e=3kfdNU

Observed

The PresentationDocument.Open throw the UriFormatException exception

System.UriFormatException: 'Invalid URI: The hostname could not be parsed.'

Because the ppt\slides_rels\slide1.xml.rels contain this string

<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="mailto:!@#$%^&amp;*()_+}{:”?&gt;&lt;,./;’[]=-098766554321" TargetMode="External"/>

As you can see, the Target is not an uri.

Expected

We can design an exception handle API, and we can handle some illegal document.

See #38 #274 #297 #298

And the #298 only add more information but can not tolerate errors.

And just as @twsouthwick says, we can not fix this in the OpenXML SDK project #297 (comment) , but I think we can tolerate some errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions