concrete/src/File/Service/File.php
public function sanitize($file)
    {
        // Let's build an ASCII-only version of name, to avoid filesystem-specific encoding issues.
        $asciiName = Core::make('helper/text')->asciify($file);
        // Let's keep only letters, numbers, underscore and dots.
        $asciiName = trim(preg_replace(["/[\\s]/", "/[^0-9A-Z_a-z-.]/"], ["_", ""], $asciiName));
        // Trim underscores at start and end
        $asciiName = trim($asciiName, '_');
        if (!strlen(str_replace('.', '', $asciiName))) {
            // If the resulting name is empty (or we have only dots in it)
            $asciiName = md5($file);
        } elseif (preg_match('/^\.\w+$/', $asciiName)) {
            // If the resulting name is only composed by the file extension
            $asciiName = md5($file) . $asciiName;
        }

        return $asciiName;
    }
public function sanitize($file)
    {
        // Let's build an ASCII-only version of name, to avoid filesystem-specific encoding issues.
        $asciiName = Core::make('helper/text')->asciify($file);
        // Let's keep only letters, numbers, underscore and dots.
        $asciiName = trim(preg_replace(["/[\\s]/", "/[^0-9A-Z_a-z-.]/"], ["_", ""], $asciiName));
        // Trim underscores at start and end
        $asciiName = trim($asciiName, '_');
        if (!strlen(str_replace('.', '', $asciiName))) {
            // If the resulting name is empty (or we have only dots in it)
            $asciiName = md5($file);
        } elseif (preg_match('/^\.\w+$/', $asciiName)) {
            // If the resulting name is only composed by the file extension
            $asciiName = md5($file) . $asciiName;
        }

        return $asciiName;
    }
public function sanitize ( $ file ) { // Let's build an ASCII-only version of name, to avoid filesystem-specific encoding issues. $ asciiName = Core :: make ( 'helper/text' ) -> asciify ( $ file ) ; // Let's keep only letters, numbers, underscore and dots. $ asciiName = trim ( preg_replace ( [ "/[\\s]/" , "/[^0-9A-Z_a-z-.]/" ] , [ "_" , "" ] , $ asciiName ) ) ; // Trim underscores at start and end $ asciiName = trim ( $ asciiName , '_' ) ; if ( ! strlen ( str_replace ( '.' , '' , $ asciiName ) ) ) { // If the resulting name is empty (or we have only dots in it) $ asciiName = md5 ( $ file ) ; } elseif ( preg_match ( '/^\.\w+$/' , $ asciiName ) ) { // If the resulting name is only composed by the file extension $ asciiName = md5 ( $ file ) . $ asciiName ; } return $ asciiName ; }
Cleans up a filename and returns the cleaned up version.

@param string $file

@return string
Cleans up a filename and returns the cleaned up version .