One illegal uri in Relationship will destroy the document parsing
See original GitHub issueDescription
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:!@#$%^&*()_+}{:”?><,./;’[]=-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.
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 https://github.com/OfficeDev/Open-XML-SDK/issues/297#issuecomment-345560540 , but I think we can tolerate some errors
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:29 (21 by maintainers)
See #1295 for the package abstraction being proposed