* (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.
This commit is contained in:
Brion Vibber 2006-06-06 23:50:16 +00:00
parent ec377a67c4
commit 02ff859a87
3 changed files with 7 additions and 4 deletions

View 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 ==

View 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

View 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