X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FParser.php;h=5d5c4b4a111590dea58bfd75a41d5eb5584b0e99;hb=8da9fca6c03fa8b2ca8bc83f8704e1219aa3904d;hp=74e92bab07717a1aa8e0b0100f6be2e06e45dcb4;hpb=d8e90514ab1a80545fad0dbe420a61480b177104;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Parser.php b/includes/Parser.php index 74e92bab07..5d5c4b4a11 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -157,7 +157,16 @@ class Parser wfRunHooks( 'ParserClearState', array( &$this ) ); } - /** + /** + * Accessor for mUniqPrefix. + * + * @access public + */ + function UniqPrefix() { + return $this->mUniqPrefix; + } + + /** * Convert wikitext to HTML * Do not call this function recursively. * @@ -175,8 +184,8 @@ class Parser * First pass--just handle sections, pass the rest off * to internalParse() which does all the real work. */ - - global $wgUseTidy, $wgContLang; + + global $wgUseTidy, $wgAlwaysUseTidy, $wgContLang; $fname = 'Parser::parse'; wfProfileIn( $fname ); @@ -236,8 +245,8 @@ class Parser wfRunHooks( 'ParserBeforeTidy', array( &$this, &$text ) ); $text = Sanitizer::normalizeCharReferences( $text ); - - if ($wgUseTidy) { + + if (($wgUseTidy and $this->mOptions->mTidy) or $wgAlwaysUseTidy) { $text = Parser::tidy($text); } @@ -498,7 +507,7 @@ class Parser if ( !is_array( $state ) ) { return $text; } - + # Must expand in reverse order, otherwise nested tags will be corrupted foreach( array_reverse( $state, true ) as $tag => $contentDict ) { if( $tag != 'nowiki' && $tag != 'html' ) { @@ -683,7 +692,7 @@ class Parser $fc = substr ( $x , 0 , 1 ) ; if ( preg_match( '/^(:*)\{\|(.*)$/', $x, $matches ) ) { $indent_level = strlen( $matches[1] ); - + $attributes = $this->unstripForHTML( $matches[2] ); $t[$k] = str_repeat( '
', $indent_level ) . @@ -1112,19 +1121,23 @@ class Parser # Replace & from obsolete syntax with &. # All HTML entities will be escaped by makeExternalLink() - # or maybeMakeExternalImage() $url = str_replace( '&', '&', $url ); + # Replace unnecessary URL escape codes with the referenced character + # This prevents spammers from hiding links from the filters + $url = Parser::replaceUnusualEscapes( $url ); # Process the trail (i.e. everything after this link up until start of the next link), # replacing any non-bracketed links $trail = $this->replaceFreeExternalLinks( $trail ); - # Use the encoded URL # This means that users can paste URLs directly into the text # Funny characters like ö aren't valid in URLs anyway # This was changed in August 2004 $s .= $sk->makeExternalLink( $url, $text, false, $linktype ) . $dtrail . $trail; + + # Register link in the output object + $this->mOutput->addExternalLink( $url ); } wfProfileOut( $fname ); @@ -1180,12 +1193,16 @@ class Parser # All HTML entities will be escaped by makeExternalLink() # or maybeMakeExternalImage() $url = str_replace( '&', '&', $url ); + # Replace unnecessary URL escape codes with their equivalent characters + $url = Parser::replaceUnusualEscapes( $url ); # Is this an external image? $text = $this->maybeMakeExternalImage( $url ); if ( $text === false ) { # Not an image, make a link $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free' ); + # Register it in the output object + $this->mOutput->addExternalLink( $url ); } $s .= $text . $trail; } else { @@ -1196,6 +1213,36 @@ class Parser return $s; } + /** + * Replace unusual URL escape codes with their equivalent characters + * @param string + * @return string + * @static + */ + function replaceUnusualEscapes( $url ) { + return preg_replace_callback( '/%[0-9A-Fa-f]{2}/', + array( 'Parser', 'replaceUnusualEscapesCallback' ), $url ); + } + + /** + * Callback function used in replaceUnusualEscapes(). + * Replaces unusual URL escape codes with their equivalent character + * @static + * @access private + */ + function replaceUnusualEscapesCallback( $matches ) { + $char = urldecode( $matches[0] ); + $ord = ord( $char ); + // Is it an unsafe or HTTP reserved character according to RFC 1738? + if ( $ord > 32 && $ord < 127 && strpos( '<>"#{}|\^~[]`;/?', $char ) === false ) { + // No, shouldn't be escaped + return $char; + } else { + // Yes, leave it escaped + return $matches[0]; + } + } + /** * make an image if it's allowed, either through the global * option or through the exception @@ -1206,7 +1253,7 @@ class Parser $imagesfrom = $this->mOptions->getAllowExternalImagesFrom(); $imagesexception = !empty($imagesfrom); $text = false; - if ( $this->mOptions->getAllowExternalImages() + if ( $this->mOptions->getAllowExternalImages() || ( $imagesexception && strpos( $url, $imagesfrom ) === 0 ) ) { if ( preg_match( EXT_IMAGE_REGEX, $url ) ) { # Image found @@ -1421,7 +1468,7 @@ class Parser # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them $s .= $prefix . $this->armorLinks( $this->makeImage( $nt, $text ) ) . $trail; - $this->mOutput->addImage( $nt->getDBkey() ); + $this->mOutput->addImage( $nt->getDBkey() ); wfProfileOut( "$fname-image" ); continue; @@ -1522,7 +1569,7 @@ class Parser } return $retVal; } - + /** * Render a forced-blue link inline; protect against double expansion of * URLs if we're in a mode that prepends full URL prefixes to internal links. @@ -1543,7 +1590,7 @@ class Parser $link = $sk->makeKnownLinkObj( $nt, $text, $query, $inside, $prefix ); return $this->armorLinks( $link ) . $trail; } - + /** * Insert a NOPARSE hacky thing into any inline links in a chunk that's * going to go through further parsing steps before inline URL expansion. @@ -1954,6 +2001,8 @@ class Parser return $varCache[$index] = $wgContLang->getMonthAbbreviation( date( 'n', $ts ) ); case MAG_CURRENTDAY: return $varCache[$index] = $wgContLang->formatNum( date( 'j', $ts ) ); + case MAG_CURRENTDAY2: + return $varCache[$index] = $wgContLang->formatNum( date( 'd', $ts ) ); case MAG_PAGENAME: return $this->mTitle->getText(); case MAG_PAGENAMEE: @@ -1975,7 +2024,9 @@ class Parser case MAG_CURRENTTIME: return $varCache[$index] = $wgContLang->time( wfTimestamp( TS_MW, $ts ), false, false ); case MAG_CURRENTWEEK: - return $varCache[$index] = $wgContLang->formatNum( date( 'W', $ts ) ); + // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to + // int to remove the padding + return $varCache[$index] = $wgContLang->formatNum( (int)date( 'W', $ts ) ); case MAG_CURRENTDOW: return $varCache[$index] = $wgContLang->formatNum( date( 'w', $ts ) ); case MAG_NUMBEROFARTICLES: @@ -2048,14 +2099,14 @@ class Parser if ($lastOpeningBrace >= 0) { $pos = strpos ($text, $openingBraceStack[$lastOpeningBrace]['braceEnd'], $i); - + if (false !== $pos && (-1 == $nextPos || $pos < $nextPos)){ $rule = null; $nextPos = $pos; } $pos = strpos ($text, '|', $i); - + if (false !== $pos && (-1 == $nextPos || $pos < $nextPos)){ $rule = null; $nextPos = $pos; @@ -2075,14 +2126,14 @@ class Parser 'title' => '', 'parts' => null); - # count openning brace characters + # count openning brace characters while ($i+1 < strlen($text) && $text[$i+1] == $piece['brace']) { $piece['count']++; $i++; } - $piece['startAt'] = $i+1; - $piece['partStart'] = $i+1; + $piece['startAt'] = $i+1; + $piece['partStart'] = $i+1; # we need to add to stack only if openning brace count is enough for any given rule foreach ($rule['cb'] as $cnt => $fn) { @@ -2116,7 +2167,7 @@ class Parser $matchingCallback = $fn; } } - + if ($matchingCount == 0) { $i += $count - 1; continue; @@ -2130,7 +2181,7 @@ class Parser $pieceStart = $openingBraceStack[$lastOpeningBrace]['startAt'] - $matchingCount; $pieceEnd = $i + $matchingCount; - + if( is_callable( $matchingCallback ) ) { $cbArgs = array ( 'text' => substr($text, $pieceStart, $pieceEnd - $pieceStart), @@ -2181,7 +2232,7 @@ class Parser } else $openingBraceStack[$lastOpeningBrace]['parts'][] = substr($text, $openingBraceStack[$lastOpeningBrace]['partStart'], $i - $openingBraceStack[$lastOpeningBrace]['partStart']); - + $openingBraceStack[$lastOpeningBrace]['partStart'] = $i + 1; } } @@ -2308,6 +2359,8 @@ class Parser $found = false; $nowiki = false; $noparse = false; + $replaceHeadings = false; + $isHTML = false; $title = NULL; @@ -2372,7 +2425,7 @@ class Parser # Check for NS: (namespace expansion) $mwNs = MagicWord::get( MAG_NS ); if ( $mwNs->matchStartAndRemove( $part1 ) ) { - if ( intval( $part1 ) ) { + if ( intval( $part1 ) || $part1 == "0" ) { $text = $linestart . $wgContLang->getNsText( intval( $part1 ) ); $found = true; } else { @@ -2412,7 +2465,7 @@ class Parser $mwLocalE =& MagicWord::get( MAG_LOCALURLE ); $mwFull =& MagicWord::get( MAG_FULLURL ); $mwFullE =& MagicWord::get( MAG_FULLURLE ); - + if ( $mwLocal->matchStartAndRemove( $part1 ) ) { $func = 'getLocalURL'; @@ -2480,8 +2533,6 @@ class Parser } # Load from database - $replaceHeadings = false; - $isHTML = false; $lastPathLevel = $this->mTemplatePath; if ( !$found ) { $ns = NS_TEMPLATE; @@ -2491,49 +2542,51 @@ class Parser } $title = Title::newFromText( $part1, $ns ); - if ($title) { - $interwiki = Title::getInterwikiLink($title->getInterwiki()); - if ($interwiki != '' && $title->isTrans()) { - return $this->scarytransclude($title, $interwiki); - } - } - - if ( !is_null( $title ) && !$title->isExternal() ) { - # Check for excessive inclusion - $dbk = $title->getPrefixedDBkey(); - if ( $this->incrementIncludeCount( $dbk ) ) { - if ( $title->getNamespace() == NS_SPECIAL && $this->mOptions->getAllowSpecialInclusion() ) { - # Capture special page output - $text = SpecialPage::capturePath( $title ); - if ( is_string( $text ) ) { - $found = true; - $noparse = true; - $isHTML = true; - $this->disableCache(); - } - } else { - $article = new Article( $title ); - $articleContent = $article->fetchContent(0, false); - if ( $articleContent !== false ) { - $found = true; - $text = $articleContent; - $replaceHeadings = true; + if ( !is_null( $title ) ) { + if ( !$title->isExternal() ) { + # Check for excessive inclusion + $dbk = $title->getPrefixedDBkey(); + if ( $this->incrementIncludeCount( $dbk ) ) { + if ( $title->getNamespace() == NS_SPECIAL && $this->mOptions->getAllowSpecialInclusion() ) { + # Capture special page output + $text = SpecialPage::capturePath( $title ); + if ( is_string( $text ) ) { + $found = true; + $noparse = true; + $isHTML = true; + $this->disableCache(); + } + } else { + $articleContent = $this->fetchTemplate( $title ); + if ( $articleContent !== false ) { + $found = true; + $text = $articleContent; + $replaceHeadings = true; + } } - # Register a template reference whether or not the template exists - $this->mOutput->addTemplate( $title, $article->getID() ); } - } - # If the title is valid but undisplayable, make a link to it - if ( $this->mOutputType == OT_HTML && !$found ) { - $text = '[['.$title->getPrefixedText().']]'; - $found = true; - } + # If the title is valid but undisplayable, make a link to it + if ( $this->mOutputType == OT_HTML && !$found ) { + $text = '[['.$title->getPrefixedText().']]'; + $found = true; + } - # Template cache array insertion - if( $found ) { - $this->mTemplates[$part1] = $text; - $text = $linestart . $text; + # Template cache array insertion + if( $found ) { + $this->mTemplates[$part1] = $text; + $text = $linestart . $text; + } + } elseif ( $title->isTrans() ) { + // Interwiki transclusion + if ( $this->mOutputType == OT_HTML ) { + $text = $this->interwikiTransclude( $title, 'render' ); + $isHTML = true; + $noparse = true; + } else { + $text = $this->interwikiTransclude( $title, 'raw' ); + } + $found = true; } } } @@ -2575,7 +2628,7 @@ class Parser # Remove sections and tags $text = preg_replace( '/.*?<\/noinclude>/s', '', $text ); $text = strtr( $text, array( '' => '' , '' => '' ) ); - + if( $this->mOutputType == OT_HTML ) { # Strip ,
, etc.
 				$text = $this->strip( $text, $this->mStripState );
@@ -2642,43 +2695,73 @@ class Parser
 			return $text;
 		}
 	}
-	
+
+	/**
+	 * Fetch the unparsed text of a template and register a reference to it. 
+	 */
+	function fetchTemplate( $title ) {
+		$text = false;
+		// Loop to fetch the article, with up to 1 redirect
+		for ( $i = 0; $i < 2 && is_object( $title ); $i++ ) {
+			$rev = Revision::newFromTitle( $title );
+			$this->mOutput->addTemplate( $title, $title->getArticleID() );
+			if ( !$rev ) {
+				break;
+			}
+			$text = $rev->getText();
+			if ( $text === false ) {
+				break;
+			}
+			// Redirect?
+			$title = Title::newFromRedirect( $text );
+		}
+		return $text;
+	}
+
 	/**
-	 * Translude an interwiki link.
+	 * Transclude an interwiki link.
 	 */
-	function scarytransclude($title, $interwiki) {
-		global $wgEnableScaryTranscluding;
+	function interwikiTransclude( $title, $action ) {
+		global $wgEnableScaryTranscluding, $wgCanonicalNamespaceNames;
 
 		if (!$wgEnableScaryTranscluding)
 			return wfMsg('scarytranscludedisabled');
 
-		$articlename = "Template:" . $title->getDBkey();
-		$url = str_replace('$1', urlencode($articlename), $interwiki);
+		// The namespace will actually only be 0 or 10, depending on whether there was a leading :
+		// But we'll handle it generally anyway
+		if ( $title->getNamespace() ) {
+			// Use the canonical namespace, which should work anywhere
+			$articleName = $wgCanonicalNamespaceNames[$title->getNamespace()] . ':' . $title->getDBkey();
+		} else {
+			$articleName = $title->getDBkey();
+		}
+
+		$url = str_replace('$1', urlencode($articleName), Title::getInterwikiLink($title->getInterwiki()));
+		$url .= "?action=$action";
 		if (strlen($url) > 255)
 			return wfMsg('scarytranscludetoolong');
-		$text = $this->fetchScaryTemplateMaybeFromCache($url);
-		$this->mIWTransData[] = $text;
-		return "";
+		return $this->fetchScaryTemplateMaybeFromCache($url);
 	}
 
 	function fetchScaryTemplateMaybeFromCache($url) {
+		global $wgTranscludeCacheExpiry;
 		$dbr =& wfGetDB(DB_SLAVE);
 		$obj = $dbr->selectRow('transcache', array('tc_time', 'tc_contents'),
 				array('tc_url' => $url));
 		if ($obj) {
 			$time = $obj->tc_time;
 			$text = $obj->tc_contents;
-			if ($time && $time < (time() + (60*60))) {
+			if ($time && time() < $time + $wgTranscludeCacheExpiry ) {
 				return $text;
 			}
 		}
 
-		$text = wfGetHTTP($url . '?action=render');
+		$text = wfGetHTTP($url);
 		if (!$text)
 			return wfMsg('scarytranscludefailed', $url);
 
 		$dbw =& wfGetDB(DB_MASTER);
-		$dbw->replace('transcache', array(), array(
+		$dbw->replace('transcache', array('tc_url'), array(
 			'tc_url' => $url,
 			'tc_time' => time(),
 			'tc_contents' => $text));
@@ -3131,14 +3214,6 @@ class Parser
 	function pstPass2( $text, &$user ) {
 		global $wgContLang, $wgLocaltimezone;
 
-		# Variable replacement
-		# Because mOutputType is OT_WIKI, this will only process {{subst:xxx}} type tags
-		$text = $this->replaceVariables( $text );
-
-		# Signatures
-		#
-		$sigText = $this->getUserSig( $user );
-
 		/* Note: This is the timestamp saved as hardcoded wikitext to
 		 * the database, we use $wgContLang here in order to give
 		 * everyone the same signiture and use the default one rather
@@ -3154,16 +3229,24 @@ class Parser
 			putenv( 'TZ='.$oldtz );
 		}
 
-		$text = preg_replace( '/~~~~~/', $d, $text );
-		$text = preg_replace( '/~~~~/', "$sigText $d", $text );
-		$text = preg_replace( '/~~~/', $sigText, $text );
+		# Variable replacement
+		# Because mOutputType is OT_WIKI, this will only process {{subst:xxx}} type tags
+		$text = $this->replaceVariables( $text );
+		
+		# Signatures
+		$sigText = $this->getUserSig( $user );
+		$text = strtr( $text, array( 
+			'~~~~~' => $d,
+			'~~~~' => "$sigText $d",
+			'~~~' => $sigText
+		) );
 
 		# Context links: [[|name]] and [[name (context)|]]
 		#
 		global $wgLegalTitleChars;
 		$tc = "[$wgLegalTitleChars]";
 		$np = str_replace( array( '(', ')' ), array( '', '' ), $tc ); # No parens
-		
+
 		$namespacechar = '[ _0-9A-Za-z\x80-\xff]'; # Namespaces can use non-ascii!
 		$conpat = "/^({$np}+) \\(({$tc}+)\\)$/";
 
@@ -3195,7 +3278,7 @@ class Parser
 
 		return $text;
 	}
-	
+
 	/**
 	 * Fetch the user's signature text, if any, and normalize to
 	 * validated, ready-to-insert wikitext.
@@ -3205,53 +3288,60 @@ class Parser
 	 * @access private
 	 */
 	function getUserSig( &$user ) {
-		$name = $user->getName();
-		$nick = trim( $user->getOption( 'nickname' ) );
-		if ( '' == $nick ) {
-			$nick = $name;
-		}
-		
-		if( $user->getOption( 'fancysig' ) ) {
-			// A wikitext signature.
-			$valid = $this->validateSig( $nick );
-			if( $valid === false ) {
-				// Fall back to default sig
-				$nick = $name;
-				wfDebug( "Parser::getUserSig: $name has bad XML tags in signature.\n" );
+		global $wgContLang;
+
+		$username = $user->getName();
+		$nickname = $user->getOption( 'nickname' );
+		$nickname = $nickname === '' ? $username : $nickname;
+	
+		if( $user->getBoolOption( 'fancysig' ) !== false ) {
+			# Sig. might contain markup; validate this
+			if( $this->validateSig( $nickname ) !== false ) {
+				# Validated; clean up (if needed) and return it
+				return( $this->cleanSig( $nickname ) );
 			} else {
-				return $nick;
+				# Failed to validate; fall back to the default
+				$nickname = $username;
+				wfDebug( "Parser::getUserSig: $username has bad XML tags in signature.\n" );
 			}
 		}
-		
-		// Plain text linking to the user's homepage
-		global $wgContLang;
-		$page = $user->getUserPage();
-		return '[[' .
-			$page->getPrefixedText() .
-			"|" .
-			wfEscapeWikIText( $nick ) .
-			"]]";
+
+		# If we're still here, make it a link to the user page
+		$userpage = $user->getUserPage();
+		return( '[[' . $userpage->getPrefixedText() . '|' . wfEscapeWikiText( $nickname ) . ']]' );
 	}
-	
+
 	/**
-	 * We want to enforce two rules on wikitext sigs here:
-	 * 1) Expand any templates at save time (forced subst:)
-	 * 2) Check for unbalanced XML tags, and reject if so.
+	 * Check that the user's signature contains no bad XML
 	 *
 	 * @param string $text
 	 * @return mixed An expanded string, or false if invalid.
-	 *
-	 * @todo Run brace substitutions
-	 * @todo ?? Check for unbalanced '' and ''' quotes, etc
 	 */
 	function validateSig( $text ) {
-		if( wfIsWellFormedXmlFragment( $text ) ) {
-			return $text;
-		} else {
-			return false;
-		}
+		return( wfIsWellFormedXmlFragment( $text ) ? $text : false );
 	}
+	
+	/**
+	 * Clean up signature text
+	 *
+	 * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures
+	 * 2) Substitute all transclusions
+	 *
+	 * @param string $text
+	 * @return string Signature text
+	 */
+	function cleanSig( $text ) {
+		$substWord = MagicWord::get( MAG_SUBST );
+		$substRegex = '/\{\{(?!(?:' . $substWord->getBaseRegex() . '))/x' . $substWord->getRegexCase();
+		$substText = '{{' . $substWord->getSynonym( 0 );
 
+		$text = preg_replace( $substRegex, $substText, $text );
+		$text = preg_replace( '/~{3,5}/', '', $text );
+		$text = $this->replaceVariables( $text );
+	
+		return $text;
+	}
+	
 	/**
 	 * Set up some variables which are usually set up in parse()
 	 * so that an external function can call some class members with confidence
@@ -3278,12 +3368,16 @@ class Parser
 		global $wgTitle;
 		static $executing = false;
 
+		$fname = "Parser::transformMsg";
+
 		# Guard against infinite recursion
 		if ( $executing ) {
 			return $text;
 		}
 		$executing = true;
 
+		wfProfileIn($fname);
+
 		$this->mTitle = $wgTitle;
 		$this->mOptions = $options;
 		$this->mOutputType = OT_MSG;
@@ -3291,6 +3385,7 @@ class Parser
 		$text = $this->replaceVariables( $text );
 
 		$executing = false;
+		wfProfileOut($fname);
 		return $text;
 	}
 
@@ -3309,7 +3404,7 @@ class Parser
 	function setHook( $tag, $callback ) {
 		$oldVal = @$this->mTagHooks[$tag];
 		$this->mTagHooks[$tag] = $callback;
-		
+
 		return $oldVal;
 	}
 
@@ -3640,14 +3735,14 @@ class Parser
 	}
 
 	/**
-	 * Set a flag in the output object indicating that the content is dynamic and 
+	 * Set a flag in the output object indicating that the content is dynamic and
 	 * shouldn't be cached.
 	 */
 	function disableCache() {
 		$this->mOutput->mCacheTime = -1;
 	}
-	
-	/**
+
+	/**#@+ 
 	 * Callback from the Sanitizer for expanding items found in HTML attribute
 	 * values, so they can be safely tested and escaped.
 	 * @param string $text
@@ -3660,16 +3755,27 @@ class Parser
 		$text = $this->unstripForHTML( $text );
 		return $text;
 	}
-	
+
 	function unstripForHTML( $text ) {
 		$text = $this->unstrip( $text, $this->mStripState );
 		$text = $this->unstripNoWiki( $text, $this->mStripState );
 		return $text;
 	}
+	/**#@-*/
 
+	/**#@+
+	 * Accessor/mutator
+	 */
 	function Title( $x = NULL ) { return wfSetVar( $this->mTitle, $x ); }
 	function Options( $x = NULL ) { return wfSetVar( $this->mOptions, $x ); }
 	function OutputType( $x = NULL ) { return wfSetVar( $this->mOutputType, $x ); }
+	/**#@-*/
+
+	/**#@+
+	 * Accessor
+	 */
+	function getTags() { return array_keys( $this->mTagHooks ); }
+	/**#@-*/
 }
 
 /**
@@ -3687,7 +3793,8 @@ class ParserOutput
 		$mTitleText,        # title text of the chosen language variant
 		$mLinks,            # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken.
 		$mTemplates,        # 2-D map of NS/DBK to ID for the template references. ID=zero for broken.
-		$mImages;           # DB keys of the images used, in the array key only
+		$mImages,           # DB keys of the images used, in the array key only
+		$mExternalLinks;    # External link URLs, in the key only
 
 	function ParserOutput( $text = '', $languageLinks = array(), $categoryLinks = array(),
 		$containsOldMagic = false, $titletext = '' )
@@ -3702,6 +3809,7 @@ class ParserOutput
 		$this->mLinks = array();
 		$this->mTemplates = array();
 		$this->mImages = array();
+		$this->mExternalLinks = array();
 	}
 
 	function getText()                   { return $this->mText; }
@@ -3713,6 +3821,7 @@ class ParserOutput
 	function &getLinks()                 { return $this->mLinks; }
 	function &getTemplates()             { return $this->mTemplates; }
 	function &getImages()                { return $this->mImages; }
+	function &getExternalLinks()         { return $this->mExternalLinks; }
 
 	function containsOldMagic()          { return $this->mContainsOldMagic; }
 	function setText( $text )            { return wfSetVar( $this->mText, $text ); }
@@ -3725,19 +3834,20 @@ class ParserOutput
 	function addCategory( $c, $sort )    { $this->mCategories[$c] = $sort; }
 	function addImage( $name )           { $this->mImages[$name] = 1; }
 	function addLanguageLink( $t )       { $this->mLanguageLinks[] = $t; }
+	function addExternalLink( $url )     { $this->mExternalLinks[$url] = 1; }
 
-	function addLink( $title, $id ) { 
+	function addLink( $title, $id ) {
 		$ns = $title->getNamespace();
 		$dbk = $title->getDBkey();
 		if ( !isset( $this->mLinks[$ns] ) ) {
 			$this->mLinks[$ns] = array();
 		}
-		$this->mLinks[$ns][$dbk] = $id; 
+		$this->mLinks[$ns][$dbk] = $id;
 	}
 
 	function addTemplate( $title, $id ) {
 		$ns = $title->getNamespace();
-		$dbk = $title->getDBkey();	
+		$dbk = $title->getDBkey();
 		if ( !isset( $this->mTemplates[$ns] ) ) {
 			$this->mTemplates[$ns] = array();
 		}
@@ -3791,6 +3901,7 @@ class ParserOptions
 	var $mEditSection;               # Create "edit section" links
 	var $mNumberHeadings;            # Automatically number headings
 	var $mAllowSpecialInclusion;     # Allow inclusion of special pages
+	var $mTidy;	        	 # Ask for tidy cleanup
 
 	function getUseTeX()                        { return $this->mUseTeX; }
 	function getUseDynamicDates()               { return $this->mUseDynamicDates; }
@@ -3802,7 +3913,7 @@ class ParserOptions
 	function getEditSection()                   { return $this->mEditSection; }
 	function getNumberHeadings()                { return $this->mNumberHeadings; }
 	function getAllowSpecialInclusion()         { return $this->mAllowSpecialInclusion; }
-
+	function getTidy()		            { return $this->mTidy; }
 
 	function setUseTeX( $x )                    { return wfSetVar( $this->mUseTeX, $x ); }
 	function setUseDynamicDates( $x )           { return wfSetVar( $this->mUseDynamicDates, $x ); }
@@ -3813,7 +3924,7 @@ class ParserOptions
 	function setEditSection( $x )               { return wfSetVar( $this->mEditSection, $x ); }
 	function setNumberHeadings( $x )            { return wfSetVar( $this->mNumberHeadings, $x ); }
 	function setAllowSpecialInclusion( $x )     { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
-
+	function setTidy( $x )			    { return wfSetVar( $this->mTidy, $x); }
 	function setSkin( &$x ) { $this->mSkin =& $x; }
 
 	function ParserOptions() {
@@ -3856,6 +3967,7 @@ class ParserOptions
 		$this->mEditSection = true;
 		$this->mNumberHeadings = $user->getOption( 'numberheadings' );
 		$this->mAllowSpecialInclusion = $wgAllowSpecialInclusion;
+		$this->mTidy = false;
 		wfProfileOut( $fname );
 	}
 }