IDEA-106589 100% CPU on completion in invalid XML
(cherry picked from commit 45c660a)