Extension talk:RandomArea

Security(?) flaw
There is a security(?) flaw known. "It totally breaks the wiki if you try to randomly output anything that has only 1 character, like a single digit. So inserting

1

2

3

4

generates an endless loop."

Therefor the source is edited and updated.

 'Random Area', 'version' => ( ' '.RANDOM_AREA_VERSION.' ' ) , 'author' => 'Loki' , );

function ylRandomAreaExtension { global $wgParser; $wgParser->setHook( "randomArea", "renderRandomArea" ); }

function renderRandomArea( $input, $argv, $parser ) { $count = $argv['count']; if ($count < 0 || !$count) { $count = 1; }	$nsPrefix = $argv['nsprefix']; $include = (bool) $argv['include']; $values = explode("\n", $input); $valCount = count($values) - 1; if ($valCount < $count) { return $parser->internalParse("Exception: Array out of Bounce - > 		Only ".$valCount." items available, count = ".$count ); }	$valueIndex = array; $randOut = ""; $i = 0; while ($i < $count ) { $randVal = rand(0, $valCount); $randTemp = trim($values[$randVal]); if (strlen($randTemp) >= 1 && !array_key_exists($randVal, $valueIndex)) { if (strlen($nsPrefix) > 1) { $randOutTemp = $nsPrefix.$randTemp; } else { $randOutTemp = $randTemp; }			if ($include) { $randOut .= ""; } else { $randOut .= $randOutTemp; }			$valueIndex[$randVal] = true; }			$i++; }	return $parser->internalParse($randOut); }

} else { echo( "This is an extension to the MediaWiki package and cannot be run standalone.\n" ); die( -1 ); }

Code update thanks to Steffen