-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RelationshipErrorHandlerFactory fails with "Data at the root level is invalid" #883
Comments
Update on this. Turns out my hack to resolve the issue comes with a glaring issue.
If the output produced is over 265 characters, it blows up with:
|
Oh good catch on the bufferring! Probably need to set the stream to 0 before writing it. I'm fairly busy right now, but will happily review PRs! As for your workaround - just subract the length of the new string part. Didn't realize there was a length limit there |
@twsouthwick Just wanted to give a big thank you for helping get that fix in and the speed you got it rolled out on Nuget. Kudos to you sir! ❤️ |
Using RelationshipErrorHandlerFactory.Rewrite with an output that is shorter than the original URI causes the output XML to be malformed in this Word document.
When the above is run on a Word document with the following document.xml.rels:
It fails with "Data at the root level is invalid. Line 12, position 17." and has produced the following in the output document:
As you can see, the end part of the XML has now been malformed. This is probably a buffer issue with the shorter string being returned from the Rewrite method. I've seen this in a few places when working with the Package classes.
Extending the Rewrite output to match the length of the original URI resolves the issue:
public override string Rewrite(Uri partUri, string id, string uri) => $"https://error{new string('r', uri.Length)}";
Information
Please see example console app with sample Word document repo'ing the issue:
https://github.com/Muppets/RelationshipErrorHandlerFactoryTest
Observed
Exception thrown: System.Xml.XmlException: 'Data at the root level is invalid. Line 12, position 17.'
Expected
Invalid URI is replaced with https://error
Just as a footnote, I'm loving the new RelationshipErrorHandlerFactory support added recently, great work! 🎉
The text was updated successfully, but these errors were encountered: