const OT_WIKI = 2;
const OT_PREPROCESS = 3;
const OT_MSG = 3;
-
+
+ // Marker Suffix needs to be accessible staticly.
+ const MARKER_SUFFIX = "-QINU\x7f";
+
/**#@+
* @private
*/
# Persistent:
var $mTagHooks, $mTransparentTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables,
- $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerSuffix, $mMarkerIndex,
- $mExtLinkBracketedRegex, $mPreprocessor, $mDefaultStripList, $mVarCache, $mConf;
+ $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex, $mPreprocessor,
+ $mExtLinkBracketedRegex, $mDefaultStripList, $mVarCache, $mConf;
# Cleared with clearState():
$this->mFunctionHooks = array();
$this->mFunctionSynonyms = array( 0 => array(), 1 => array() );
$this->mDefaultStripList = $this->mStripList = array( 'nowiki', 'gallery' );
- $this->mMarkerSuffix = "-QINU\x7f";
$this->mExtLinkBracketedRegex = '/\[(\b(' . wfUrlProtocols() . ')'.
'[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x0a\\x0d]*?)\]/S';
$this->mVarCache = array();
$inside = $p[4];
}
- $marker = "$uniq_prefix-$element-" . sprintf('%08X', $n++) . $this->mMarkerSuffix;
+ $marker = "$uniq_prefix-$element-" . sprintf('%08X', $n++) . self::MARKER_SUFFIX;
$stripped .= $marker;
if ( $close === '/>' ) {
* @private
*/
function insertStripItem( $text ) {
- $rnd = "{$this->mUniqPrefix}-item-{$this->mMarkerIndex}-{$this->mMarkerSuffix}";
+ $rnd = "{$this->mUniqPrefix}-item-{$this->mMarkerIndex}-" . self::MARKER_SUFFIX;
$this->mMarkerIndex++;
$this->mStripState->general->setPair( $rnd, $text );
return $rnd;
$attrText = !isset( $params['attr'] ) ? null : $frame->expand( $params['attr'] );
$content = !isset( $params['inner'] ) ? null : $frame->expand( $params['inner'] );
- $marker = "{$this->mUniqPrefix}-$name-" . sprintf('%08X', $this->mMarkerIndex++) . $this->mMarkerSuffix;
+ $marker = "{$this->mUniqPrefix}-$name-" . sprintf('%08X', $this->mMarkerIndex++) . self::MARKER_SUFFIX;
if ( $this->ot['html'] ) {
$name = strtolower( $name );
$prevlevel = 0;
$toclevel = 0;
$prevtoclevel = 0;
- $markerRegex = "{$this->mUniqPrefix}-h-(\d+)-{$this->mMarkerSuffix}";
+ $markerRegex = "{$this->mUniqPrefix}-h-(\d+)-" . self::MARKER_SUFFIX;
$baseTitleText = $this->mTitle->getPrefixedDBkey();
$tocraw = array();
if($prevtoclevel < $wgMaxTocLevel) {
# Unindent only if the previous toc level was shown :p
$toc .= $sk->tocUnindent( $prevtoclevel - $toclevel );
+ $prevtoclevel = $toclevel;
} else {
$toc .= $sk->tocLineEnd();
}
* Parse image options text and use it to make an image
*/
function makeImage( $title, $options ) {
- # @TODO: let the MediaHandler specify its transform parameters
- #
# Check if the options text is of the form "options|alt text"
# Options are:
# * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
'horizAlign' => array(), 'vertAlign' => array() );
foreach( $parts as $part ) {
list( $magicName, $value ) = $mwArray->matchVariableStartToEnd( $part );
- if ( isset( $paramMap[$magicName] ) ) {
+ $validated = false;
+ if( isset( $paramMap[$magicName] ) ) {
list( $type, $paramName ) = $paramMap[$magicName];
- $params[$type][$paramName] = $value;
-
+
// Special case; width and height come in one variable together
if( $type == 'handler' && $paramName == 'width' ) {
$m = array();
- if ( preg_match( '/^([0-9]*)x([0-9]*)$/', $value, $m ) ) {
- $params[$type]['width'] = intval( $m[1] );
- $params[$type]['height'] = intval( $m[2] );
+ # (bug 13500) In both cases (width/height and width only),
+ # permit trailing "px" for backward compatibility.
+ if ( preg_match( '/^([0-9]*)x([0-9]*)\s*(?:px)?\s*$/', $value, $m ) ) {
+ $width = intval( $m[1] );
+ $height = intval( $m[2] );
+ if ( $handler->validateParam( 'width', $width ) ) {
+ $params[$type]['width'] = $width;
+ $validated = true;
+ }
+ if ( $handler->validateParam( 'height', $height ) ) {
+ $params[$type]['height'] = $height;
+ $validated = true;
+ }
+ } elseif ( preg_match( '/^[0-9]*\s*(?:px)?\s*$/', $value ) ) {
+ $width = intval( $value );
+ if ( $handler->validateParam( 'width', $width ) ) {
+ $params[$type]['width'] = $width;
+ $validated = true;
+ }
+ } // else no validation -- bug 13436
+ } else {
+ if ( $type == 'handler' ) {
+ # Validate handler parameter
+ $validated = $handler->validateParam( $paramName, $value );
} else {
- $params[$type]['width'] = intval( $value );
+ # Validate internal parameters
+ $validated = ( $value === false || is_numeric( trim( $value ) ) );
+ }
+
+ if ( $validated ) {
+ $params[$type][$paramName] = $value;
}
}
- } else {
+ }
+ if ( !$validated ) {
$caption = $part;
}
}
$params['frame']['valign'] = key( $params['vertAlign'] );
}
- # Validate the handler parameters
- if ( $handler ) {
- foreach ( $params['handler'] as $name => $value ) {
- if ( !$handler->validateParam( $name, $value ) ) {
- unset( $params['handler'][$name] );
- }
- }
- }
-
# Strip bad stuff out of the alt text
$alt = $this->replaceLinkHoldersText( $caption );
break;
} else {
$out .= call_user_func( $callback, substr( $s, $i, $markerStart - $i ) );
- $markerEnd = strpos( $s, $this->mMarkerSuffix, $markerStart );
+ $markerEnd = strpos( $s, self::MARKER_SUFFIX, $markerStart );
if ( $markerEnd === false ) {
$out .= substr( $s, $markerStart );
break;
} else {
- $markerEnd += strlen( $this->mMarkerSuffix );
+ $markerEnd += strlen( self::MARKER_SUFFIX );
$out .= substr( $s, $markerStart, $markerEnd - $markerStart );
$i = $markerEnd;
}