From 1fd0e2db0ccf31b4aada09965a1987f51784169e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 10 Jul 2008 04:47:25 +0000 Subject: [PATCH] Revert r37443 for the moment: * Code duplication of validity checks between wfIsValidFileName() and UploadForm::internalProcessUpload() -- this guarantees behavior will become inconsistent over time. Move the normalization into a single place. * The additional chars excluded for Windows don't cover the entire set of illegal chars. There are several more punctuation characters, plus general issues such as all non-ASCII characters. * Application of filesystem rules based on OS could result in strange inconsistent behavior; alternate filestore backends could support different sets of legal characters. * No clear reason for the change to wfVarDump(); var_export works just fine and doesn't use the fragile output buffering --- RELEASE-NOTES | 1 - includes/GlobalFunctions.php | 26 +------------------------- includes/Title.php | 3 --- includes/specials/SpecialUpload.php | 2 -- languages/messages/MessagesEn.php | 1 - maintenance/language/messages.inc | 1 - 6 files changed, 1 insertion(+), 33 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a03dbb62bd..0f6dc377ac 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -431,7 +431,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN on non-mySQL schemas. * (bug 14763) Child classes of Database (DatabasePostgres and DatabaseOracle) had stict standards issues with setFakeSlaveLag() and setFakeMaster(). -* Image now can't contain "*" or "?" characters under Windows === API changes in 1.13 === diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 2f1b60b552..b7ac5d1375 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -862,10 +862,7 @@ function wfMerge( $old, $mine, $yours, &$result ){ */ function wfVarDump( $var ) { global $wgOut; - ob_start(); - var_dump( $var ); - $s = str_replace("\n","
\n", ob_get_contents() . "\n"); - ob_end_clean(); + $s = str_replace("\n","
\n", var_export( $var, true ) . "\n"); if ( headers_sent() || !@is_object( $wgOut ) ) { print $s; } else { @@ -2367,24 +2364,3 @@ function wfGenerateToken( $salt = '' ) { return md5( mt_rand( 0, 0x7fffffff ) . $salt ); } - -/** - * Checks filename for validity - * @param mixed $title Filename or title to check - */ -function wfIsValidFileName( $name ) { - if( !$name instanceof Title ) - if( !Title::makeTitleSafe( NS_IMAGE, $name ) ) - return false; - else - $name = $name->getText(); - - if( in_string( ':', $name ) ) - return false; - elseif( wfBaseName( $name ) != $name ) - return false; - elseif( wfIsWindows() && ( in_string( '*', $name ) || in_string( '?', $name ) ) ) - return false; - else - return true; -} diff --git a/includes/Title.php b/includes/Title.php index f481311251..972d3fc842 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2443,9 +2443,6 @@ class Title { if( $nt->getNamespace() != NS_IMAGE ) { $errors[] = array('imagenocrossnamespace'); } - if( !wfIsValidFileName( $nt ) ) { - $errors[] = array('imageinvalidfilename'); - } if( !File::checkExtensionCompatibility( $file, $nt->getDbKey() ) ) { $errors[] = array('imagetypemismatch'); } diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php index 5567c8d506..2b3873a8b6 100644 --- a/includes/specials/SpecialUpload.php +++ b/includes/specials/SpecialUpload.php @@ -427,8 +427,6 @@ class UploadForm { * out of it. We'll strip some silently that Title would die on. */ $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $filtered ); - if( wfIsWindows() ) - $filtered = preg_replace ( "/[*?]/", '-', $filtered ); $nt = Title::makeTitleSafe( NS_IMAGE, $filtered ); if( is_null( $nt ) ) { $resultDetails = array( 'filtered' => $filtered ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 8c9ebf0c3a..359da308ff 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2485,7 +2485,6 @@ cannot move a page over itself.', cannot move pages from and into that namespace.', 'imagenocrossnamespace' => 'Cannot move file to non-file namespace', 'imagetypemismatch' => 'The new file extension does not match its type', -'imageinvalidfilename' => 'Target image file name is invalid', # Export 'export' => 'Export pages', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index ba68f69ff7..6091345ffb 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1692,7 +1692,6 @@ $wgMessageStructure = array( 'immobile_namespace', 'imagenocrossnamespace', 'imagetypemismatch', - 'imageinvalidfilename', ), 'export' => array( 'export', -- 2.20.1