Commit b004243a authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4064 (Behaviour of XHTML cleanup code is inconsistent with HTML5 cleanup algorithm)

parent 2f888df6
Loading
Loading
Loading
Loading
+99 −0
Original line number Diff line number Diff line
@@ -115,6 +115,105 @@ function init__webstandards()

    $strict_form_accessibility = false; // Form fields may not be empty with this strict rule

    global $NEVER_SELFCLOSE_TAGS;
    $NEVER_SELFCLOSE_TAGS = array(
        'div' => true,
        'h1' => true,
        'h2' => true,
        'h3' => true,
        'h4' => true,
        'h5' => true,
        'h6' => true,
        'p' => true,
        'blockquote' => true,
        'pre' => true,
        'fieldset' => true,
        'figure' => true,
        'address' => true,
        'iframe' => true,
        'noscript' => true,
        'table' => true,
        'tbody' => true,
        'td' => true,
        'tfoot' => true,
        'th' => true,
        'thead' => true,
        'tr' => true,
        'dd' => true,
        'dt' => true,
        'dl' => true,
        'li' => true,
        'ol' => true,
        'ul' => true,
        'rbc' => true,
        'rtc' => true,
        'rb' => true,
        'rt' => true,
        'rp' => true,
        'video' => true,
        'details' => true,
        'summary' => true,
        'section' => true,
        'nav' => true,
        'header' => true,
        'footer' => true,
        'figure' => true,
        'canvas' => true,
        'audio' => true,
        'aside' => true,
        'article' => true,
        'span' => true,
        'abbr' => true,
        'cite' => true,
        'code' => true,
        'dfn' => true,
        'em' => true,
        'strong' => true,
        'kbd' => true,
        'q' => true,
        'samp' => true,
        'var' => true,
        'sub' => true,
        'sup' => true,
        'del' => true,
        'ruby' => true,
        'a' => true,
        'bdo' => true,
        'ins' => true,
        'textarea' => true,
        'select' => true,
        'object' => true,
        'caption' => true,
        'label' => true,
        'time' => true,
        'progress' => true,
        'output' => true,
        'meter' => true,
        'mark' => true,
        'datalist' => true,
        'body' => true,
        'colgroup' => true,
        'head' => true,
        'html' => true,
        'map' => true,
        'optgroup' => true,
        'option' => true,
        'style' => true,
        'title' => true,
        'legend' => true,
        'figcaption' => true,
        'script' => true,
        'form' => true,
        'dir' => true,
        'menu' => true,
        'center' => true,
        'applet' => true,
        'font' => true,
        's' => true,
        'strike' => true,
        'u' => true,
    );

    global $POSSIBLY_EMPTY_TAGS;
    $POSSIBLY_EMPTY_TAGS = array(
        'a' => true, // When it's an anchor only - we will detect this with custom code
+2 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ function xhtmlise_html($html, $definitely_want = false, $snippet = false)
    require_code('obfuscate');
    require_code('webstandards');

    global $XML_CONSTRAIN, $LAST_TAG_ATTRIBUTES, $POS, $OUT, $TAG_STACK, $INBETWEEN_TEXT, $LEN, $WELL_FORMED_ONLY, $MUST_SELFCLOSE_TAGS, $LINENO, $LINESTART;
    global $XML_CONSTRAIN, $LAST_TAG_ATTRIBUTES, $POS, $OUT, $TAG_STACK, $INBETWEEN_TEXT, $LEN, $WELL_FORMED_ONLY, $MUST_SELFCLOSE_TAGS, $NEVER_SELFCLOSE_TAGS, $LINENO, $LINESTART;
    $POS = 0;
    $OUT = $html;
    $LEN = strlen($html);
@@ -94,7 +94,7 @@ function xhtmlise_html($html, $definitely_want = false, $snippet = false)
            $term = strpos($token, '/');

            if ($term !== 1) {
                if (($term === false) && (!isset($MUST_SELFCLOSE_TAGS[$basis_token]))) { // Opening a tag
                if ((($term === false) || (isset($NEVER_SELFCLOSE_TAGS[$basis_token]))) && (!isset($MUST_SELFCLOSE_TAGS[$basis_token]))) { // Opening a tag
                    // Fix nesting
                    if (!$snippet) {
                        if (($basis_token == 'li') && (!in_array('ul', $TAG_STACK)) && (!in_array('ol', $TAG_STACK)) && (!in_array('dl', $TAG_STACK)) && (!in_array('dd', $TAG_STACK)) && (!in_array('dt', $TAG_STACK)) && (!in_array('dir', $TAG_STACK)) && (!in_array('menu', $TAG_STACK))) {