Handle nested li in ol or ul. That happens when someone use something like:
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 2 May 2006 18:34:28 +0000 (18:34 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 2 May 2006 18:34:28 +0000 (18:34 +0000)
<ol><li>foo<sup>bar</sup></li><li>second</li></ol>

RELEASE-NOTES
includes/Sanitizer.php

index 36336d2..42fecff 100644 (file)
@@ -185,6 +185,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Bidi-aid on list pages
 * (bug 5782) Allow entries in the bad image list to use canonical namespace names
 * (bug 5789) Treat "loginreqpagetext" as wikitext
+* Sanitizer: now handles nested <li> in <ul> or <ol>
 
 == Compatibility ==
 
index 6b63e62..7845419 100644 (file)
@@ -351,8 +351,15 @@ class Sanitizer {
                                'dl', 'font', 'big', 'small', 'sub', 'sup', 'span'
                        );
                        $tabletags = array( # Can only appear inside table
-                               'td', 'th', 'tr'
+                               'td', 'th', 'tr',
                        );
+                       $htmllist = array( # Tags used by list
+                               'ul','ol',
+                       );
+                       $listtags = array( # Tags that can appear in a list
+                               'li',
+                       );
+
                } else {
                        $htmlpairs = array();
                        $htmlsingle = array();
@@ -385,7 +392,10 @@ class Sanitizer {
                                                        $badtag = 1;
                                                } elseif ( ( $ot = @array_pop( $tagstack ) ) != $t ) {
                                                        @array_push( $tagstack, $ot );
-                                                       $badtag = 1;
+                                                       # <li> can be nested in <ul> or <ol>, skip those cases:
+                                                       if(!(in_array($ot, $htmllist) && in_array($t, $listtags) )) {
+                                                               $badtag = 1;
+                                                       }
                                                } else {
                                                        if ( $t == 'table' ) {
                                                                $tagstack = array_pop( $tablestack );