Fix incorrect decreasing of nesting level in NamespaceResolver#974
Fix incorrect decreasing of nesting level in NamespaceResolver#974weiznich wants to merge 1 commit into
Conversation
This commit fixes an incorrect decreasing of the nesting level in the NamespaceResolver through the ns_reader. We could end up there in a state where we request a future decreasing of the nesting level without pushing an actual increase. This could cause namespaces to be unregistered too early. Fix tafia#953
| Ok(Event::End(e)) => { | ||
| // push a fake element to the `ns_resolver` as the pending pop will remove it again | ||
| // if we don't push this element we don't increase the level, but the subsequent pending pop will | ||
| // decrease it anyway. | ||
| self.ns_resolver.push(&BytesStart::new(""))?; |
There was a problem hiding this comment.
This will only mask the issue in some cases. As described, the root cause lies in the event rewind code, that does not save/restore snapshots of NamespaceResolver state. The correct fix should implement such snapshoting.
There was a problem hiding this comment.
I run out of time looking again at this this week. I cannot promise that I find time to have a in depth look anytime soon due to other priorities. It still would be helpful to have some more details about the fix you are thinking of, as this would make it easier to schedule some fixed amount of time for the fix instead of require a vague amount of time.
There was a problem hiding this comment.
Now I do not have any clear vision of what exactly the fix should look like. Definitely, we need to save the NamespaceResolver snapshot when a snapshot of events is made, but at the same time we don't want to save unnecessary (for example, if the XML nesting is very deep and there are dozens of namespace definitions at each level), then we don't want to duplicate all this bunch of information just to keep the last level.
This commit fixes an incorrect decreasing of the nesting level in the NamespaceResolver through the ns_reader. We could end up there in a state where we request a future decreasing of the nesting level without pushing an actual increase. This could cause namespaces to be unregistered too early.
Fix #953