* (bug 3837) Leave <center> as is instead of doing an unsafe text replacement
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 6 Jun 2006 23:50:16 +0000 (23:50 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 6 Jun 2006 23:50:16 +0000 (23:50 +0000)
  to <div class="center">. <center> is perfectly valid in the target doctype
  (XHTML 1.0 Transitional), while the replacement didn't catch all cases and
  could even result in invalid output from valid input.

RELEASE-NOTES
includes/Parser.php
maintenance/parserTests.txt

index 838a4cb..488aaa6 100644 (file)
@@ -446,6 +446,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 3202) Attributes now allowed on <pre> tags
 * Sanitizer::validateTagAttributes now available to discard illegal/unsafe
   attribute values from an array.
+* (bug 3837) Leave <center> as is instead of doing an unsafe text replacement
+  to <div class="center">. <center> is perfectly valid in the target doctype
+  (XHTML 1.0 Transitional), while the replacement didn't catch all cases and
+  could even result in invalid output from valid input. 
 
 
 == Compatibility ==
index 52df980..61de1bf 100644 (file)
@@ -248,7 +248,6 @@ class Parser
                        '/(.) (?=\\?|:|;|!|\\302\\273)/' => '\\1&nbsp;\\2',
                        # french spaces, Guillemet-right
                        '/(\\302\\253) /' => '\\1&nbsp;',
-                       '/<center *>(.*)<\\/center *>/i' => '<div class="center">\\1</div>',
                );
                $text = preg_replace( array_keys($fixtags), array_values($fixtags), $text );
 
@@ -1891,10 +1890,10 @@ class Parser
                                wfProfileIn( "$fname-paragraph" );
                                # No prefix (not in list)--go to paragraph mode
                                // XXX: use a stack for nestable elements like span, table and div
-                               $openmatch = preg_match('/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<li|<\\/tr|<\\/td|<\\/th)/iS', $t );
+                               $openmatch = preg_match('/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<li|<center|<\\/tr|<\\/td|<\\/th)/iS', $t );
                                $closematch = preg_match(
                                        '/(<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'.
-                                       '<td|<th|<div|<\\/div|<hr|<\\/pre|<\\/p|'.$this->mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol)/iS', $t );
+                                       '<td|<th|<div|<\\/div|<hr|<\\/pre|<\\/p|'.$this->mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol|<\\/center)/iS', $t );
                                if ( $openmatch or $closematch ) {
                                        $paragraphStack = false;
                                        # TODO bug 5718: paragraph closed
index a6a8aec..ceaf0f5 100644 (file)
@@ -3957,7 +3957,7 @@ Self closed html pairs (bug 5487)
 <center><font id="bug" />Centered text</center>
 <div><font id="bug2" />In div text</div>
 !! result
-<div class="center">&lt;font id="bug" /&gt;Centered text</div>
+<center>&lt;font id="bug" /&gt;Centered text</center>
 <div>&lt;font id="bug2" /&gt;In div text</div>
 
 !! end