New attributes may cause a StackOverflowError for toHtml()
Brought to you by:
derrickoswald
After adding new attributes to a document, the call to the toHtml() method may cause a StackOverflowError.
In the provided example, the StackOverflowError occurs only if attributes are added with the nodevisitor.
java code to reproduce error
Logged In: YES
user_id=832167
Originator: YES
I have looked into the source code and there's a problem when an attribute is added to an empty tag.
For example, I have a tag <div id="someId"/> in my html file. In the attributes list for this tag, the last attribute is "/". However when I add an attribute, this attribute is added to the end of the list. So "/" is not the last attribute anymore. That's why, when I call the toHtml() method, the method isEmptyXmlTag() returns false for the tag and that provokes an infinite loop because <div> is a composite tag and in my example, its end tag is itself.
Hope that helps :)
Logged In: YES
user_id=832167
Originator: YES
I have looked into the source code and there's a problem when an attribute is added to an empty tag.
For example, I have a tag <div id="someId"/> in my html file. In the attributes list for this tag, the last attribute is "/". However when I add an attribute, this attribute is added to the end of the list. So "/" is not the last attribute anymore. That's why, when I call the toHtml() method, the method isEmptyXmlTag() returns false for the tag and that provokes an infinite loop because <div> is a composite tag and in my example, its end tag is itself.
Hope that helps :)
Logged In: YES
user_id=605407
Originator: NO
I believe this is the same issue as bug #1761484 tag.setAttribute() not compatible with <tag/> which has been fixed.