Skip to content

Commit

Permalink
- fix buggy renaming of files containing _ or -
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyborn committed Sep 3, 2018
1 parent ae41e83 commit 5a08464
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions classes/CheckFilenames.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,11 @@ public static function sanitizeFileOrFolderName( $strName ) {

$newName = $strName;

// cut name to length
if( !\Config::get('doNotTrimFilenames') ) {
$newName = substr( $newName, 0, 32 );
}
// convert to lowercase
$newName = strtolower($newName);

// remove forbidden characters
$newName = preg_replace("/[\W_]+/", '', $newName);
$newName = preg_replace("/[^a-z0-9-_]+/", '', $newName);
$newName = standardize( \StringUtil::restoreBasicEntities($newName) );

// remove 'id-' from the beginning
Expand All @@ -105,6 +103,11 @@ public static function sanitizeFileOrFolderName( $strName ) {
// replace double underscores
$newName = self::replaceUnderscores($newName);

// cut name to length
if( !\Config::get('doNotTrimFilenames') ) {
$newName = substr( $newName, 0, 32 );
}

return $newName;
}

Expand Down

0 comments on commit 5a08464

Please sign in to comment.