CDATA - The document appears to be corrupted and cannot be loaded

If a document has custom xml that contains a CDATA section, then loading the document will throw a FileCorruptedException. The following code can be used to duplicate the problem:

// using Aspose.Words for .NET v16.7.0.0

var doc = new Document();

doc.CustomXmlParts.Add(new CustomXmlPart { Id = Guid.NewGuid().ToString(), Data = Encoding.UTF8.GetBytes(@"") });

var fn = Path.Combine(Path.GetTempPath(), "cdata.xml");

doc.Save(fn, SaveFormat.FlatOpc);

// opening the document will throw the following exception:
//Aspose.Words.FileCorruptedException: The document appears to be corrupted and cannot be loaded. —>System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
//Parameter name: Unexpected XML event type: CDATA
//   at   .(XmlTextReader , StringBuilder ,  ,    )
//   at   .(XmlTextReader ,    )
//   at    .(   )
//   at   .(    )
//   at   .(Stream )
//   at   . ()
//   at    . ()
//   at    .()
//   at    .()
//   at    .(Stream , Encoding )
//   at Aspose.Words.Document.(Stream , LoadOptions )
//   — End of inner exception stack trace —
//   at Aspose.Words.Document.(Stream , LoadOptions )
//   at Aspose.Words.Document.(Stream , LoadOptions )
//   at Aspose.Words.Document…ctor(String fileName, LoadOptions loadOptions)
//   at Aspose.Words.Document…ctor(String fileName)
//   at ConsoleApplication2.Program.Main(String []
//		args) in C:\temp\ConsoleApplication2\Program.cs:line 25
var doc2 = new Document(fn);

Thank you

Hi Kahn,

Thanks for your inquiry. Could you please attach your input Word document here for testing? We will investigate the issue on our side and provide you more information.

The code sample that I provided will produce the attached file.

Thank you

Hi Kahn,

Thanks for sharing the detail. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-14030. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thanks for logging this issue Tahir. I wanted to let you know that addressing this would be greatly appreciated.

Thanks again

Hi Kahn,

Thanks for your inquiry. Unfortunately, your issue is not resolved yet. We have asked the ETA of this issue from our product team and will update you as soon as any estimates are available. We apologize for any inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-14030) have been fixed in this Aspose.Words for .NET 16.12.0 update and this Aspose.Words for Java 16.12.0 update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.