Uploaded image for project: 'SonarHTML'
  1. SonarHTML
  2. SONARHTML-2

Improve the handling of unclosed tags

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.2
    • Component/s: Parsing
    • Labels:
      None

      Description

      Some tags in HTML 4 are not supposed to be closed, such as <li>:

      <ul>
        <li>foo
        <li>bar
      </ul>
      

      There should be some additional logic to know that the 2nd <li> is not nested within the first one.

      The same applies to <p> for example, which do not nest.

      Moreover, in general, if we do find a closing tag for some tag, we should assume that all previous tags were closed, as in:

      <foo>
        <bar>...
      </foo>       <!-- When we hit this, the stack of unclosed tags is set to foo,bar - we should implicitly close bar as well as foo -->
      

      HTML5
      Html5 specification define a list of void elements that cannot have any child nodes and for witch the end tag or self-closing tag is optional.

      complete list of the void elements in HTML : area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr

      Our html parser creates a wrong node hierarchy for elements following a void element. Considering them as children and not siblings.
      For exemple, in <br><p></p>, br end tag is not missing and p is a sibling of br and not a child.
      It's like if void elements are implicit self-closing tags, <br> is equivalent to <br/>

      Note: Once the node hierarchy is fixed, VideoTrackCheck can be simplified to not look for descendant nodes but just children.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tibor.blenessy Tibor Blenessy
              Reporter:
              dinesh.bolkensteyn Dinesh Bolkensteyn (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: