r14627 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14626‎ | r14627 | r14628 >
Date:23:50, 6 June 2006
Author:brion
Status:old
Tags:
Comment:
* (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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -3957,7 +3957,7 @@
39583958 <center><font id="bug" />Centered text</center>
39593959 <div><font id="bug2" />In div text</div>
39603960 !! result
3961 -<div class="center">&lt;font id="bug" /&gt;Centered text</div>
 3961+<center>&lt;font id="bug" /&gt;Centered text</center>
39623962 <div>&lt;font id="bug2" /&gt;In div text</div>
39633963
39643964 !! end
Index: trunk/phase3/includes/Parser.php
@@ -248,7 +248,6 @@
249249 '/(.) (?=\\?|:|;|!|\\302\\273)/' => '\\1&nbsp;\\2',
250250 # french spaces, Guillemet-right
251251 '/(\\302\\253) /' => '\\1&nbsp;',
252 - '/<center *>(.*)<\\/center *>/i' => '<div class="center">\\1</div>',
253252 );
254253 $text = preg_replace( array_keys($fixtags), array_values($fixtags), $text );
255254
@@ -1891,10 +1890,10 @@
18921891 wfProfileIn( "$fname-paragraph" );
18931892 # No prefix (not in list)--go to paragraph mode
18941893 // XXX: use a stack for nestable elements like span, table and div
1895 - $openmatch = preg_match('/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<li|<\\/tr|<\\/td|<\\/th)/iS', $t );
 1894+ $openmatch = preg_match('/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<li|<center|<\\/tr|<\\/td|<\\/th)/iS', $t );
18961895 $closematch = preg_match(
18971896 '/(<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'.
1898 - '<td|<th|<div|<\\/div|<hr|<\\/pre|<\\/p|'.$this->mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol)/iS', $t );
 1897+ '<td|<th|<div|<\\/div|<hr|<\\/pre|<\\/p|'.$this->mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol|<\\/center)/iS', $t );
18991898 if ( $openmatch or $closematch ) {
19001899 $paragraphStack = false;
19011900 # TODO bug 5718: paragraph closed
Index: trunk/phase3/RELEASE-NOTES
@@ -446,6 +446,10 @@
447447 * (bug 3202) Attributes now allowed on <pre> tags
448448 * Sanitizer::validateTagAttributes now available to discard illegal/unsafe
449449 attribute values from an array.
 450+* (bug 3837) Leave <center> as is instead of doing an unsafe text replacement
 451+ to <div class="center">. <center> is perfectly valid in the target doctype
 452+ (XHTML 1.0 Transitional), while the replacement didn't catch all cases and
 453+ could even result in invalid output from valid input.
450454
451455
452456 == Compatibility ==

Status & tagging log