whitespaces killing

This commit is contained in:
Antoine Musso 2007-01-17 19:48:48 +00:00
parent cf40af4049
commit d228f80fc2
2 changed files with 36 additions and 36 deletions

View file

@ -114,7 +114,7 @@ class Parser
$ot, // Shortcut alias, see setOutputType()
$mRevisionId, // ID to display in {{REVISIONID}} tags
$mRevisionTimestamp, // The timestamp of the specified revision ID
$mRevIdForTs; // The revision ID which was used to fetch the timestamp
$mRevIdForTs; // The revision ID which was used to fetch the timestamp
/**#@-*/
@ -211,7 +211,7 @@ class Parser
'titles' => array()
);
$this->mRevisionTimestamp = $this->mRevisionId = null;
/**
* Prefix for temporary replacement strings for the multipass parser.
* \x07 should never appear in input as it's disallowed in XML.
@ -871,7 +871,7 @@ class Parser
array_push ( $td_history , false );
array_push ( $last_tag_history , '' );
}
else if ( $first_character == '|' || $first_character == '!' || substr ( $line , 0 , 2 ) == '|+' ) {
else if ( $first_character == '|' || $first_character == '!' || substr ( $line , 0 , 2 ) == '|+' ) {
// This might be cell elements, td, th or captions
if ( substr ( $line , 0 , 2 ) == '|+' ) {
$first_character = '+';
@ -1782,7 +1782,7 @@ class Parser
if( in_array( $nt->getPrefixedText(), $selflink, true ) ) {
$s .= $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail );
continue;
}
}
}
# Special and Media are pseudo-namespaces; no pages actually exist in them
@ -2852,7 +2852,7 @@ class Parser
return $text;
}
/// Clean up argument array - refactored in 1.9 so parserfunctions can use it, too.
static function createAssocArgs( $args ) {
$assocArgs = array();
@ -2872,10 +2872,10 @@ class Parser
}
}
}
return $assocArgs;
}
/**
* Return the text of a template, after recursively
* replacing any variables or templates within the template.
@ -3271,7 +3271,7 @@ class Parser
return wfMsg('scarytranscludedisabled');
$url = $title->getFullUrl( "action=$action" );
if (strlen($url) > 255)
return wfMsg('scarytranscludetoolong');
return $this->fetchScaryTemplateMaybeFromCache($url);
@ -4157,8 +4157,8 @@ class Parser
if(isset($categoryMap[$vardbk])){
$oldkey = $categoryMap[$vardbk];
if($oldkey != $vardbk)
$varCategories[$oldkey]=$vardbk;
}
$varCategories[$oldkey]=$vardbk;
}
}
// rebuild the categories in original order (if there are replacements)
@ -4635,7 +4635,7 @@ class Parser
}
/**
* Get the timestamp associated with the current revision, adjusted for
* Get the timestamp associated with the current revision, adjusted for
* the default server-local timestamp
*/
function getRevisionTimestamp() {
@ -4645,13 +4645,13 @@ class Parser
$dbr =& wfGetDB( DB_SLAVE );
$timestamp = $dbr->selectField( 'revision', 'rev_timestamp',
array( 'rev_id' => $this->mRevisionId ), __METHOD__ );
// Normalize timestamp to internal MW format for timezone processing.
// This has the added side-effect of replacing a null value with
// the current time, which gives us more sensible behavior for
// previews.
$timestamp = wfTimestamp( TS_MW, $timestamp );
// The cryptic '' timezone parameter tells to use the site-default
// timezone offset instead of the user settings.
//
@ -4659,12 +4659,12 @@ class Parser
// to other users, and potentially even used inside links and such,
// it needs to be consistent for all visitors.
$this->mRevisionTimestamp = $wgContLang->userAdjust( $timestamp, '' );
wfProfileOut( __METHOD__ );
}
return $this->mRevisionTimestamp;
}
/**
* Mutator for $mDefaultSort
*
@ -4673,7 +4673,7 @@ class Parser
public function setDefaultSort( $sort ) {
$this->mDefaultSort = $sort;
}
/**
* Accessor for $mDefaultSort
* Will use the title/prefixed title if none is set
@ -4689,7 +4689,7 @@ class Parser
: $this->mTitle->getPrefixedText();
}
}
}
/**

View file

@ -330,11 +330,11 @@ class Sanitizer {
static function removeHTMLtags( $text, $processCallback = null, $args = array() ) {
global $wgUseTidy, $wgUserHtml;
static $htmlpairs, $htmlsingle, $htmlsingleonly, $htmlnest, $tabletags,
static $htmlpairs, $htmlsingle, $htmlsingleonly, $htmlnest, $tabletags,
$htmllist, $listtags, $htmlsingleallowed, $htmlelements, $staticInitialised;
wfProfileIn( __METHOD__ );
if ( !$staticInitialised ) {
if( $wgUserHtml ) {
$htmlpairs = array( # Tags that must be closed
@ -396,7 +396,7 @@ class Sanitizer {
} else {
$slash = $t = $params = $brace = $rest = null;
}
$badtag = 0 ;
if ( isset( $htmlelements[$t = strtolower( $t )] ) ) {
# Check our stack
@ -645,15 +645,15 @@ class Sanitizer {
if( trim( $text ) == '' ) {
return '';
}
$stripped = Sanitizer::validateTagAttributes(
Sanitizer::decodeTagAttributes( $text ), $element );
$attribs = array();
foreach( $stripped as $attribute => $value ) {
$encAttribute = htmlspecialchars( $attribute );
$encValue = Sanitizer::safeEncodeAttribute( $value );
$attribs[] = "$encAttribute=\"$encValue\"";
}
return count( $attribs ) ? ' ' . implode( ' ', $attribs ) : '';
@ -666,7 +666,7 @@ class Sanitizer {
*/
static function encodeAttribute( $text ) {
$encValue = htmlspecialchars( $text );
// Whitespace is normalized during attribute decoding,
// so if we've been passed non-spaces we must encode them
// ahead of time or they won't be preserved.
@ -675,10 +675,10 @@ class Sanitizer {
"\r" => '
',
"\t" => '	',
) );
return $encValue;
}
/**
* Encode an attribute value for HTML tags, with extra armoring
* against further wiki processing.
@ -687,7 +687,7 @@ class Sanitizer {
*/
static function safeEncodeAttribute( $text ) {
$encValue = Sanitizer::encodeAttribute( $text );
# Templates and links may be expanded in later parsing,
# creating invalid or dangerous output. Suppress this.
$encValue = strtr( $encValue, array(
@ -795,11 +795,11 @@ class Sanitizer {
foreach( $pairs as $set ) {
$attribute = strtolower( $set[1] );
$value = Sanitizer::getTagAttributeCallback( $set );
// Normalize whitespace
$value = preg_replace( '/[\t\r\n ]+/', ' ', $value );
$value = trim( $value );
// Decode character references
$attribs[$attribute] = Sanitizer::decodeCharReferences( $value );
}
@ -1215,7 +1215,7 @@ class Sanitizer {
$out .= "]>\n";
return $out;
}
static function cleanUrl( $url, $hostname=true ) {
# Normalize any HTML entities in input. They will be
# re-escaped by makeExternalLink().
@ -1223,12 +1223,12 @@ class Sanitizer {
# Escape any control characters introduced by the above step
$url = preg_replace( '/[\][<>"\\x00-\\x20\\x7F]/e', "urlencode('\\0')", $url );
# Validate hostname portion
$matches = array();
if( preg_match( '!^([^:]+:)(//[^/]+)?(.*)$!iD', $url, $matches ) ) {
list( /* $whole */, $protocol, $host, $rest ) = $matches;
// Characters that will be ignored in IDNs.
// http://tools.ietf.org/html/3454#section-3.1
// Strip them before further processing so blacklists and such work.
@ -1247,11 +1247,11 @@ class Sanitizer {
\xe2\x80\x8d| # 200d ZERO WIDTH JOINER
[\xef\xb8\x80-\xef\xb8\x8f] # fe00-fe00f VARIATION SELECTOR-1-16
/xuD";
$host = preg_replace( $strip, '', $host );
// @fixme: validate hostnames here
return $protocol . $host . $rest;
} else {
return $url;