Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#437 noscript tag parsing incorrect

closed-fixed
Wolfgang Fahl
None
5
2012-09-12
2009-10-21
Matthias Hanisch
No

This is more or less a reopen of Bug Id 1969106. I am using 1.7.
I got a java.lang.NullPointerException
at com.meterware.httpunit.WebResponse.readTags(WebResponse.java:1145)
The HTML paged ends with a strange (invalid?) noscript tag in the following way:
<html>
...
</body>
</html><noscript>t</noscript>

The while-loop in readTags() method does not stop on the end tag, but on any other tag - because of the missing "!" in the while test.
In this case, the getNextTag() method reaches the document end and return null, which leads to the Exception above.
Changing the while test in the following way
while (!tag.getName().equalsIgnoreCase( "/noscript") );
fixes the problem.

Discussion

  • Test class

     
    Attachments
  • I added a test class. First test "testNoscriptAtEnd" shows the problem described above.
    Second test shows that there are more problems with the "noscript" part of that method. If there is no closing tag, then we get still a NullPointerException at the end of the document.
    The following while-loop survives with both test cases:
    do {
    tag = parser.getNextTag();
    if (tag == null) {
    // end of document
    return;
    }
    }
    while (!tag.getName().equalsIgnoreCase( "/noscript") );

     
  • Wolfgang Fahl
    Wolfgang Fahl
    2012-09-12

    The change is now in the subversion repository and will be in the next build

     
  • Wolfgang Fahl
    Wolfgang Fahl
    2012-09-12

    • assigned_to: nobody --> wolfgang_fahl
    • status: open --> closed-fixed