r2962 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r2961‎ | r2962 | r2963 >
Date:13:59, 4 April 2004
Author:gabrielwicke
Status:old
Tags:
Comment:
* anchor stripping now positively defined, only a few explicitly defined invalid characters are replaced by _:
$canonized_headline = preg_replace("/[ &\\/<>\\(\\)\\[\\]=,+]+/", '_', html_entity_decode(trim( $canonized_headline )));
* additional fixes for closing p's in tables
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -377,9 +377,9 @@
378378
379379 $l = array_pop ( $ltd ) ;
380380 if ( array_pop ( $td ) ) $z = "</{$l}>" . $z ;
381 - if ( $fc == "|" ) $l = "TD" ;
382 - else if ( $fc == "!" ) $l = "TH" ;
383 - else if ( $fc == "+" ) $l = "CAPTION" ;
 381+ if ( $fc == "|" ) $l = "td" ;
 382+ else if ( $fc == "!" ) $l = "th" ;
 383+ else if ( $fc == "+" ) $l = "caption" ;
384384 else $l = "" ;
385385 array_push ( $ltd , $l ) ;
386386 $y = explode ( "|" , $theline , 2 ) ;
@@ -418,6 +418,8 @@
419419
420420 # $text = preg_replace( "/(^|\n)-----*/", "\\1<hr>", $text );
421421 $text = str_replace ( "<HR>", "<hr />", $text );
 422+ $text = str_replace ( "<br>", "<br />", $text );
 423+ $text = str_replace ( "<br >", "<br />", $text );
422424
423425 $text = $this->doHeadings( $text );
424426
@@ -1025,7 +1027,7 @@
10261028 "/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<div|<pre)/i", $t ) ) {
10271029 $text .= $this->closeParagraph();
10281030 $inBlockElem = true;
1029 - } else if ( preg_match("/(<hr)/i", $t ) ) {
 1031+ } else if ( preg_match("/(<hr|<\\/td)/i", $t ) ) {
10301032 $text .= $this->closeParagraph();
10311033 $inBlockElem = false;
10321034 }
@@ -1468,8 +1470,7 @@
14691471 # strip out HTML
14701472 $canonized_headline = preg_replace( "/<.*?" . ">/","",$canonized_headline );
14711473
1472 - $tocline = trim( $canonized_headline );
1473 - $canonized_headline = preg_replace( "/[^a-z0-9]/i", "_", trim( $canonized_headline ) );
 1474+ $canonized_headline = preg_replace("/[ &\\/<>\\(\\)\\[\\]=,+]+/", '_', html_entity_decode(trim( $canonized_headline )));
14741475 $refer[$headlineCount] = $canonized_headline;
14751476
14761477 # count how many in assoc. array so we can track dupes in anchors

Status & tagging log