From: Gabriel Wicke Date: Mon, 12 Apr 2004 16:10:17 +0000 (+0000) Subject: doBlockLevels and fixtags only in parse(), restored amp regex, ? not valid in anchor... X-Git-Tag: 1.3.0beta1~452 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=f39b48539b8f449588d1c263d2e1076bc1f0004f;p=lhc%2Fweb%2Fwiklou.git doBlockLevels and fixtags only in parse(), restored amp regex, ? not valid in anchor names --- diff --git a/includes/Parser.php b/includes/Parser.php index 7927aa5268..5594f9efaf 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -91,7 +91,20 @@ class Parser $stripState = NULL; $text = $this->strip( $text, $this->mStripState ); $text = $this->internalParse( $text, $linestart ); + # only once and next-to-last + $text = $this->doBlockLevels( $text, $linestart ); $text = $this->unstrip( $text, $this->mStripState ); + # Clean up special characters, only run once and last + $fixtags = array( + "/
/i" => '
', + "/
/i" => '
', + "/
/i"=>'', + "/<\\/center *>/i" => '', + # Clean up spare ampersands; note that we probably ought to be + # more careful about named entities. + '/&(?!:amp;|#[Xx][0-9A-fa-f]+;|#[0-9]+;|[a-zA-Z0-9]+;)/' => '&' + ); + $text = preg_replace( array_keys($fixtags), array_values($fixtags), $text ); $this->mOutput->setText( $text ); wfProfileOut( $fname ); @@ -469,26 +482,9 @@ class Parser $text = $this->formatHeadings( $text ); $sk =& $this->mOptions->getSkin(); $text = $sk->transformContent( $text ); - - $fixtags = array( - "/
/i" => '
', - "/
/i" => '
', - "/
/i"=>'', - "/<\\/center *>/i" => '' - ); - $text = preg_replace( array_keys($fixtags), array_values($fixtags), $text ); - // another round, but without regex - $fixtags = array( - '& ' => '&', - '&<' => '&<', - ); - $text = str_replace( array_keys($fixtags), array_values($fixtags), $text ); - + $text .= $this->categoryMagic () ; - # needs to be called last - $text = $this->doBlockLevels( $text, $linestart ); - wfProfileOut( $fname ); return $text; } @@ -1621,7 +1617,7 @@ class Parser # strip out HTML $canonized_headline = preg_replace( "/<.*?" . ">/","",$canonized_headline ); $tocline = trim( $canonized_headline ); - $canonized_headline = preg_replace("/[ &\\/<>\\(\\)\\[\\]=,+']+/", '_', html_entity_decode( $tocline)); + $canonized_headline = preg_replace("/[ \\?&\\/<>\\(\\)\\[\\]=,+']+/", '_', html_entity_decode( $tocline)); $refer[$headlineCount] = $canonized_headline; # count how many in assoc. array so we can track dupes in anchors