Revert r44271 "(bug 12998) Weaken DISPLAYTITLE restictions (patch by 'rememberthedot...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 10 Dec 2008 23:21:28 +0000 (23:21 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 10 Dec 2008 23:21:28 +0000 (23:21 +0000)
Behavior seems a bit hard to predict, as far as what's going to go in the header and what in the browser window etc. Pulling it back for further testing and discussion.

includes/EditPage.php
includes/OutputPage.php
includes/Skin.php
includes/parser/CoreParserFunctions.php
includes/parser/ParserOutput.php
skins/Modern.php
skins/MonoBook.php

index a287455..ea4c056 100644 (file)
@@ -1083,11 +1083,11 @@ class EditPage {
                        # Use the title defined by DISPLAYTITLE magic word when present
                        if ( isset($this->mParserOutput)
                         && ( $dt = $this->mParserOutput->getDisplayTitle() ) !== false ) {
-                               $wgOut->setPageTitle( wfMsg( 'editing', $this->mParserOutput->getDisplayTitleH1() ) );
-                               $wgOut->setHTMLTitle( wfMsg( 'editing', $dt ) ); #override the HTML that setPageTitle slated for inclusion in the <title>
+                               $title = $dt;
                        } else {
-                               $wgOut->setPageTitle( wfMsg( 'editing', $wgTitle->getPrefixedText() ) );
+                               $title = $wgTitle->getPrefixedText();
                        }
+                       $wgOut->setPageTitle( wfMsg( 'editing', $title ) );
                }
        }
 
index 121a56a..dcd5c30 100644 (file)
@@ -309,10 +309,7 @@ class OutputPage {
                }
        }
 
-       # "HTML title" means <title>
-       public function setHTMLTitle( $name ) { $this->mHTMLtitle = $name; }
-       
-       # "Page title" means <h1>
+       public function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; }
        public function setPageTitle( $name ) {
                global $action, $wgContLang;
                $name = $wgContLang->convert($name, true);
@@ -323,7 +320,7 @@ class OutputPage {
                                $name .= ' - '.$taction;
                        }
                }
-               
+
                $this->setHTMLTitle( wfMsg( 'pagetitle', $name ) );
        }
        public function getHTMLTitle() { return $this->mHTMLtitle; }
@@ -542,10 +539,8 @@ class OutputPage {
                        }
                }
                // Display title
-               if( ( $displayTitleText = $parserOutput->getDisplayTitle() ) !== false ) {
-                       $this->setPageTitle( $parserOutput->getDisplayTitleH1() );
-                       $this->setHTMLTitle( wfMsg( 'pagetitle', $displayTitleText ) ); #override the HTML that setPageTitle slated for inclusion in the <title>
-               }
+               if( ( $dt = $parserOutput->getDisplayTitle() ) !== false )
+                       $this->setPageTitle( $dt );
 
                // Hooks registered in the object
                global $wgParserOutputHooks;
index 2ae8d27..d02c077 100644 (file)
@@ -1014,7 +1014,7 @@ END;
 
        function pageTitle() {
                global $wgOut;
-               $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
+               $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
                return $s;
        }
 
index ca03435..4a21b56 100644 (file)
@@ -164,32 +164,17 @@ class CoreParserFunctions {
         * @param string $text Desired title text
         * @return string
         */
-       static function displaytitle( $parser, $displayTitleH1 = '', $displayTitleTitle = '' ) {
+       static function displaytitle( $parser, $text = '' ) {
                global $wgRestrictDisplayTitle;
-               
-               $titleHTML = Sanitizer::removeHTMLtags( $displayTitleH1 ); #escape the bad tags
-               $titleText = trim( Sanitizer::stripAllTags( $titleHTML ) ); #remove the good tags, leaving the bad tags escaped, and trim it to make sure it comes out pretty
-               
-               #the user can put any sanitized text into the page title used in the <title> attribute, since it is not copy-pasteable like the <h1> tag
-               if ($displayTitleTitle == '') {
-                       $parser->mOutput->setDisplayTitle( $titleText ); #use the stripped contents of <h1>
-               } else {
-                       $parser->mOutput->setDisplayTitle( $displayTitleTitle ); #use what the user explicitly requested, MediaWiki escapes this automatically before it is served out
-               }
-               
+               $text = trim( Sanitizer::decodeCharReferences( $text ) );
+
                if ( !$wgRestrictDisplayTitle ) {
-                       $parser->mOutput->setDisplayTitleH1( $titleHTML );
+                       $parser->mOutput->setDisplayTitle( $text );
                } else {
-                       #only titles that normalize to the same title are allowed in the <h1> tag
-                       $title = Title::newFromText( $titleText );
-                       
-                       if ( $title instanceof Title && $title->getFragment() == '' && $title->equals( $parser->mTitle ) ) {
-                               $parser->mOutput->setDisplayTitleH1( $titleHTML );
-                       } else {
-                               $parser->mOutput->setDisplayTitleH1( $parser->mTitle );
-                       }
+                       $title = Title::newFromText( $text );
+                       if( $title instanceof Title && $title->getFragment() == '' && $title->equals( $parser->mTitle ) )
+                               $parser->mOutput->setDisplayTitle( $text );
                }
-               
                return '';
        }
 
index 045403d..3595138 100644 (file)
@@ -29,8 +29,7 @@ class ParserOutput
        /**
         * Overridden title for display
         */
-       private $displayTitle = false; #for use in the <title> tag
-       private $displayTitleH1 = false; #for use in the <h1> tag, may contain further HTML tags
+       private $displayTitle = false;
 
        function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
                $containsOldMagic = false, $titletext = '' )
@@ -145,15 +144,6 @@ class ParserOutput
                }
        }
 
-       /**
-        * Get the title to be used for display
-        *
-        * @return string
-        */
-       public function getDisplayTitle() {
-               return $this->displayTitle;
-       }
-       
        /**
         * Override the title to be used for display
         * -- this is assumed to have been validated
@@ -164,13 +154,14 @@ class ParserOutput
        public function setDisplayTitle( $text ) {
                $this->displayTitle = $text;
        }
-       
-       public function getDisplayTitleH1() {
-               return $this->displayTitleH1;
-       }
-       
-       public function setDisplayTitleH1( $html ) {
-               $this->displayTitleH1 = $html;
+
+       /**
+        * Get the title to be used for display
+        *
+        * @return string
+        */
+       public function getDisplayTitle() {
+               return $this->displayTitle;
        }
 
        /**
index 18fd4a5..1b5e078 100644 (file)
@@ -102,7 +102,7 @@ class ModernTemplate extends QuickTemplate {
  class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
 
        <!-- heading -->
-       <div id="mw_header"><h1 id="firstHeading"><?php $this->html('title') ?></h1></div>
+       <div id="mw_header"><h1 id="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1></div>
 
        <div id="mw_main">
        <div id="mw_contentwrapper">
index 1c11fc5..38ec39c 100644 (file)
@@ -115,7 +115,7 @@ class MonoBookTemplate extends QuickTemplate {
        <div id="content">
                <a name="top" id="top"></a>
                <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
-               <h1 class="firstHeading"><?php $this->html('title'); ?></h1>
+               <h1 class="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1>
                <div id="bodyContent">
                        <h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
                        <div id="contentSub"><?php $this->html('subtitle') ?></div>