[HtmlUnit] [htmlunit:bugs] #1688 Infinite Loop in DomNode.insertBefore
RBRi via HtmlUnit-develop <[email protected]> Wed, 10 Apr 2019 17:37:32 -0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | </p/htmlunit/bugs/1688/b8213bcd6ea997f51eb6346356949de1c6a3b762.bugs@htmlunit.p.sourceforge.net> |
This is a multi-part message in MIME format.
--===============7529427180616071323==
Content-Type: multipart/related;
boundary="===============9048862978716525795=="
This is a multi-part message in MIME format.
--===============9048862978716525795==
Content-Type: multipart/alternative;
boundary="===============3872421528723022510=="
MIME-Version: 1.0
--===============3872421528723022510==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
- **status**: open --> closed
---
** [bugs:#1688] Infinite Loop in DomNode.insertBefore**
**Status:** closed
**Group:** Latest SVN
**Created:** Fri May 22, 2015 08:04 PM UTC by William Walker
**Last Updated:** Wed Apr 10, 2019 05:37 PM UTC
**Owner:** nobody
Have had HtmlUnit hang up on me executing some web pages. Below is an example url.
https://www.tablespoon.com/profile/RailNewsletterCTA?parentUrl=%252frecipes%252fcookie-stuffed-brownie-cupcakes%252f3d4d01f7-72cc-434a-ac13-f2f19c3379aa%252f%253fnicam2%253dEmail%2526nichn2%253dCore%2526niseg2%253dTBSP%2526nicreatID2%253dTBSP_05_10_2015%2526utm_source%253dEmail_newsletter%2526utm_medium%253demail%2526utm_campaign%253dTBSP_05_10_2015&disablePageView=1
After tracing into code the problem occurs when insertBefore is called and (newChild instanceof DomDocumentFragment)==true AND fragment.getChildren is not empty. In my case, the insertBefore is occuring on the same node list that it is iterating against so the iteration goes on forever.
DomNode.java
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
969: public Node insertBefore(final Node newChild, final Node refChild) {
if (newChild instanceof DomDocumentFragment) {
final DomDocumentFragment fragment = (DomDocumentFragment) newChild;
for (final DomNode child : fragment.getChildren()) {
insertBefore(child, refChild);
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/htmlunit/bugs/
To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.
--===============3872421528723022510==
MIME-Version: 1.0
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit
<div class="markdown_content"><ul>
<li><strong>status</strong>: open --> closed</li>
</ul>
<hr/>
<p><strong> <a class="alink strikethrough" href="https://sourceforge.net/p/htmlunit/bugs/1688/">[bugs:#1688]</a> Infinite Loop in DomNode.insertBefore</strong></p>
<p><strong>Status:</strong> closed<br/>
<strong>Group:</strong> Latest SVN<br/>
<strong>Created:</strong> Fri May 22, 2015 08:04 PM UTC by William Walker<br/>
<strong>Last Updated:</strong> Wed Apr 10, 2019 05:37 PM UTC<br/>
<strong>Owner:</strong> nobody</p>
<p>Have had HtmlUnit hang up on me executing some web pages. Below is an example url.</p>
<p><a href="https://www.tablespoon.com/profile/RailNewsletterCTA?parentUrl=%252frecipes%252fcookie-stuffed-brownie-cupcakes%252f3d4d01f7-72cc-434a-ac13-f2f19c3379aa%252f%253fnicam2%253dEmail%2526nichn2%253dCore%2526niseg2%253dTBSP%2526nicreatID2%253dTBSP_05_10_2015%2526utm_source%253dEmail_newsletter%2526utm_medium%253demail%2526utm_campaign%253dTBSP_05_10_2015&disablePageView=1" rel="nofollow">https://www.tablespoon.com/profile/RailNewsletterCTA?parentUrl=%252frecipes%252fcookie-stuffed-brownie-cupcakes%252f3d4d01f7-72cc-434a-ac13-f2f19c3379aa%252f%253fnicam2%253dEmail%2526nichn2%253dCore%2526niseg2%253dTBSP%2526nicreatID2%253dTBSP_05_10_2015%2526utm_source%253dEmail_newsletter%2526utm_medium%253demail%2526utm_campaign%253dTBSP_05_10_2015&disablePageView=1</a></p>
<p>After tracing into code the problem occurs when insertBefore is called and (newChild instanceof DomDocumentFragment)==true AND fragment.getChildren is not empty. In my case, the insertBefore is occuring on the same node list that it is iterating against so the iteration goes on forever.</p>
<p>DomNode.java</p>
<div class="codehilite"><pre><span></span><span class="mi">969</span><span class="o">:</span> <span class="kd">public</span> <span class="n">Node</span> <span class="n">insertBefore</span><span class="o">(</span><span class="kd">final</span> <span class="n">Node</span> <span class="n">newChild</span><span class="o">,</span> <span class="kd">final</span> <span class="n">Node</span> <span class="n">refChild</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="n">newChild</span> <span class="k">instanceof</span> <span class="n">DomDocumentFragment</span><span class="o">)</span> <span class="o">{</span>
<span class="kd">final</span> <span class="n">DomDocumentFragment</span> <span class="n">fragment</span> <span class="o">=</span> <span class="o">(</span><span class="n">DomDocumentFragment</span><span class="o">)</span> <span class="n">newChild</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="kd">final</span> <span class="n">DomNode</span> <span class="n">child</span> <span class="o">:</span> <span class="n">fragment</span><span class="o">.</span><span class="na">getChildren</span><span class="o">())</span> <span class="o">{</span>
<span class="n">insertBefore</span><span class="o">(</span><span class="n">child</span><span class="o">,</span> <span class="n">refChild</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
</pre></div>
<hr/>
<p>Sent from sourceforge.net because [email protected] is subscribed to <a href="https://sourceforge.net/p/htmlunit/bugs/">https://sourceforge.net/p/htmlunit/bugs/</a></p>
<p>To unsubscribe from further messages, a project admin can change settings at <a href="https://sourceforge.net/p/htmlunit/admin/bugs/options.">https://sourceforge.net/p/htmlunit/admin/bugs/options.</a> Or, if this is a mailing list, you can unsubscribe from the mailing list.</p></div>
--===============3872421528723022510==--
--===============9048862978716525795==--
--===============7529427180616071323==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============7529427180616071323==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
--===============7529427180616071323==--