-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
XmlReader ReadElementContentAsString Hangs if End of Document Tag Reached in Stream #1029
Comments
@iUnknwn thank you for reporting the issue, this issue needs some detailed investigations which cannot be done within .Net 5. |
@buyaa-n I'd be potentially interested, what are you asking for? I could probably write up an MSUnit/xUnit test to test for this behavior, if you're looking for something basic to demo the problem. If you're looking for a patch/PR to fix the issue, that might be a bit trickier. |
That would be very helpful for whoever would investigate it
Sure it is not easy, and it is optional/voluntary. If you are willing to contribute for test repro, finding the root cause, propose a fix or raise a PR etc., whichever level it was that would be very helpful. Thanks again! |
@buyaa-n Sorry this took so long, but I have a repo setup with test cases for this issue. It shows the issue only happens on open streams, and it specifically occurs on single-element html items. https://github.com/iUnknwn/XmlReaderBugDemo Please let me know if you need more info. |
For now I believe you should be able to use I think the fix for this should be somewhere here
but this will likely require more investigation as there are more than one XmlReader implementation in the framework. I'm moved this to 7.0 for now since we do not plan to do this investigation in 6.0 |
Given the following XML sent over a network stream:
<?xml version="1.0" encoding="utf-16"?><DeviceCommand>PlayTone</DeviceCommand>
Which is generated by the XmlWriter command:
This reader command will cause an XML reader on the server to hang until the network stream is closed:
The command fails even though the entire element was sent. This alternative command works as expected:
However, if the stream is closed, then the XmlReader is able to read the node without issue and the call to ReadElementContentAsString works as expected.
It looks like XmlReader is waiting until it gets the node after the EndElement before it returns the string, but it doesn't properly recognize the end of the root node. This appears to be undocumented behavior.
This was tested on .NET Core 3.0 on Windows.
The text was updated successfully, but these errors were encountered: