Menu

#147 Balancer fails to detect successful forced nodescreation

1.9.15
pending
nobody
5
2014-06-02
2013-03-06
Anonymous
No

Tag Balancer fails to handle the following HTML:

...
<table>
<tr>
<td>
<table>
...

The problem is the following:
- when the <TR> tag is processed, it detects that there is no <TBODY> and tries to create it.
- The creation is successful, unfortunately, the caller doesn't detect this and ignores the <TR> tag.
- When <TD> is processed, it cannot find the parent <TR> (because it was ignored), so it again forces its creation
- The creation is successful, but the caller again doesn't detect the successful node creation and ignores the <TD> tag.
- When <TABLE> is processed, it doesn't need parent, so it directly inserts it in the document creating the following structure:
<table><tbody><tr><table>.....
which is invalid and browsers ignore the inner <table> tag.

The reason for not detecting the successful creation is because of the QName handling. When the parent node for <TBODY> is forced to be created, the QName passed in is without any URI and prefix. The TBODY tag is inserted in the element stack and the rest of the filters are called. One of them is the Namespace binder, which goes and populate the URI and the prefix fields of the original instance of the QName, which is passed to the forcedStartElement method. However, the QName inserted in the element stack is copied, so the instance there is without the URI and prefix. When forceStartElement() checks whether an element was created, it compares the two instances of the QName, which are different because of the URI and the prefix.

The workaround is to disable the http://xml.org/sax/features/namespaces feature.

If I find time, I'll update test case with a patch.

Discussion

  • Marc Guillemot

    Marc Guillemot - 2014-06-02

    Which configuration do you use? With the normal settings, "

    " gets correctly parsed.

     
  • Marc Guillemot

    Marc Guillemot - 2014-06-02
    • status: open --> pending
     

Log in to post a comment.