Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7058
Modified Files:
CompositeTag.java
Log Message:
Fix StackOverflowError similar to the previous one.
Recursion in the collectInto() wasn't checking for an end tag the same as 'this'.
Scanned for other similar occurances, and fixed it in visitor code too.
Index: CompositeTag.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/CompositeTag.java,v
retrieving revision 1.72
retrieving revision 1.73
diff -C2 -d -r1.72 -r1.73
*** CompositeTag.java 19 Jan 2004 22:44:59 -0000 1.72
--- CompositeTag.java 24 Jan 2004 17:41:32 -0000 1.73
***************
*** 243,254 ****
* @return int
*/
! public int findPositionOf(String text) {
Node node;
! int loc = 0;
! for (SimpleNodeIterator e=children();e.hasMoreNodes();) {
! node = e.nextNode();
! if (node.toPlainTextString().toUpperCase().indexOf(text.toUpperCase())!=-1) {
return loc;
- }
loc++;
}
--- 243,258 ----
* @return int
*/
! public int findPositionOf(String text)
! {
Node node;
! int loc;
!
! loc = 0;
! text = text.toUpperCase ();
! for (SimpleNodeIterator e = children (); e.hasMoreNodes (); )
! {
! node = e.nextNode ();
! if (-1 != node.toPlainTextString ().toUpperCase ().indexOf (text))
return loc;
loc++;
}
***************
*** 326,330 ****
for (SimpleNodeIterator e = children(); e.hasMoreNodes ();)
e.nextNode ().collectInto (list, filter);
! if (null != getEndTag ())
getEndTag ().collectInto (list, filter);
}
--- 330,334 ----
for (SimpleNodeIterator e = children(); e.hasMoreNodes ();)
e.nextNode ().collectInto (list, filter);
! if ((null != getEndTag ()) && (this != getEndTag ())) // 2nd guard handles <tag/>
getEndTag ().collectInto (list, filter);
}
***************
*** 367,371 ****
}
}
! if (null != getEndTag ())
getEndTag ().accept (visitor);
}
--- 371,375 ----
}
}
! if ((null != getEndTag ()) && (this != getEndTag ())) // 2nd guard handles <tag/>
getEndTag ().accept (visitor);
}
***************
*** 462,465 ****
--- 466,483 ----
}
+ /**
+ * Return the text between the start tag and the end tag.
+ * @return The contents of the CompositeTag.
+ */
+ public String getStringText ()
+ {
+ String ret;
+ int start = getEndPosition ();
+ int end = mEndTag.getStartPosition ();
+ ret = getPage ().getText (start, end);
+
+ return (ret);
+ }
+
public void toString (int level, StringBuffer buffer)
{
|