MINOR: Don't include files and folders starting with an underscore in the asset system.

MINOR: Automatically rename files and folders beginning with an underscore.

From: Andrew Short <andrewjshort@gmail.com>

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@97400 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew Short 2010-01-21 22:59:19 +00:00 committed by Sam Minnee
parent 82df67ac81
commit 712cc578d9
2 changed files with 12 additions and 6 deletions

View File

@ -297,6 +297,10 @@ class File extends DataObject {
$name = ereg_replace(' +','-',trim($name));
$name = ereg_replace('[^A-Za-z0-9.+_\-]','',$name);
while($name[0] == '_' || $name[0] == '.') {
$name = substr($name, 1);
}
// We might have just turned it blank, so check again.
if(!$name) $name = 'new-folder';

View File

@ -119,11 +119,9 @@ class Folder extends File {
if(file_exists($baseDir)) {
$actualChildren = scandir($baseDir);
foreach($actualChildren as $actualChild) {
if($actualChild[0] == '.') continue; // ignore hidden files
if(substr($actualChild,0,6) == 'Thumbs') continue; // ignore windows cache stuff
if($actualChild == '_resampled') continue; // ignore the resampled copies of images
if($actualChild == '_tmp') continue; // ignore tmp folder for PhotoEditor.
if($actualChild[0] == '.' || $actualChild[0] == '_' || substr($actualChild,0,6) == 'Thumbs') {
continue;
}
// A record with a bad class type doesn't deserve to exist. It must be purged!
if(isset($hasDbChild[$actualChild])) {
@ -222,6 +220,10 @@ class Folder extends File {
$file = ereg_replace('[^A-Za-z0-9+.-]+','',$file);
$file = ereg_replace('-+', '-',$file);
while($file[0] == '_' || $file[0] == '.') {
$file = substr($file, 1);
}
$file = $this->RelativePath . $file;
Filesystem::makeFolder(dirname("$base/$file"));