Clean a proposed filename up so it can be used correctly as a filename
@param  string $filename Proposed filename
@return string           filtered filename
768645
protected function cleanupName($filename)
    {
        $filename = str_replace(array('/', '\\', ':', ' '), '_', $filename);
        // Remove dot if it starts with one
        $filename = trim($filename, '.');

        return \MUtil_File::cleanupName($filename);
    }
988007
public static function purifyBasename($basename)
    {
        $basename = (string)$basename;
        $basename = trim($basename);
        $basename = trim($basename, '\\/');

        return $basename;
    }
584532
protected function parseDateFromFilename($filename)
    {
        if ($date = \DateTime::createFromFormat(self::FILE_NAME_PATTERN, explode('_', $filename)[0])) {
            return $date;
        }

        /**
         * @deprecated handle BC break of PR #62. will be remove in 1.0-RC1.
         */
        return \DateTime::createFromFormat('H-i-s-Y-m-d', explode('_', $filename)[0]);
    }
1271987
public static function cleanFilename($filename)
    {
        return preg_replace(
            '/[^A-Za-z0-9_\-]/',
            '_',
            htmlentities(pathinfo($filename, PATHINFO_FILENAME))
        ) . '.' . preg_replace(
            '/[^A-Za-z0-9_\-]/',
            '_',
            htmlentities(pathinfo($filename, PATHINFO_EXTENSION))
        );
    }
551812
protected function cleanFileName($identifier) {

    // Convert or strip certain special characters, by convention.
    $filter = [
      ' ' => '-',
      '_' => '-',
      '/' => '-',
      '[' => '-',
      ']' => '',
    ];
    $identifier = strtr($identifier, $filter);

    // Valid characters in a clean filename identifier are:
    // - the hyphen (U+002D)
    // - the period (U+002E)
    // - a-z (U+0030 - U+0039)
    // - A-Z (U+0041 - U+005A)
    // - the underscore (U+005F)
    // - 0-9 (U+0061 - U+007A)
    // - ISO 10646 characters U+00A1 and higher
    // We strip out any character not in the above list
    $identifier = preg_replace('/[^\\x{002D}\\x{002E}\\x{0030}-\\x{0039}\\x{0041}-\\x{005A}\\x{005F}\\x{0061}-\\x{007A}\\x{00A1}-\\x{FFFF}]/u', '', $identifier);

    // Convert everything to lowercase
    return strtolower($identifier);
  }
1012052
protected function extensionOfName($fileName)
    {
        if (mb_strpos($fileName, '.') === false) {
            return mb_strtolower($fileName);
        }

        return mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
    }
493130
public function sanitizeFilename($filename)
    {
        // Remove blacklisted caharacters
        $blacklist = ['/', '\\', '\0', '*', ':', '?', '"', '<', '>', '|', '#', '&', '!', '`', ' '];
        $filename  = str_replace($blacklist, '_', $filename);

        // Avoid hidden file
        $filename = ltrim($filename, '.');

        return $filename;
    }
71671
protected function checkFileName($fileName)
    {
        $extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));

        $allow = $this->getWhitelistedExtensions();
        $block = $this->getBlacklistedExtensions();

        return  (   (false === $allow || in_array($extension, $allow))
                &&  (false === $block || ! in_array($extension, $block))
                );
    }
426056
function clean_up( $filename ) {
            global $CFG;

            unlink( "{$this->temp_dir}/$filename.tex" );
            unlink( "{$this->temp_dir}/$filename.dvi" );
            unlink( "{$this->temp_dir}/$filename.ps" );
            $convertformat = get_config('filter_tex', 'convertformat');
            unlink( "{$this->temp_dir}/$filename.{$convertformat}" );
            unlink( "{$this->temp_dir}/$filename.aux" );
            unlink( "{$this->temp_dir}/$filename.log" );
            return;
        }
55577
public static function cleanFileName(string $fileName, array $rulesets = self::FILE_NAME_RULESETS, string $separator = '-'): string {
    $slugify   = new Slugify(['rulesets' => $rulesets, 'separator' => $separator]);
    $name      = $slugify->slugify(pathinfo($fileName, PATHINFO_FILENAME));
    $extension = pathinfo($fileName, PATHINFO_EXTENSION);

    if (empty($name)) {
      $name = uniqid(self::EMPTY_FILE_NAME_PREFIX, true);
    }

    return mb_strtolower($name . '.' . $extension);
  }
1050048
public function remove($fileName)
    {
        $fileName = $this->getTargetDir() . DIRECTORY_SEPARATOR . $fileName;

        if (!file_exists($fileName)) {
            return;
        }

        unlink($fileName);
    }
1216823
private static function getClassName($filename)
    {
        $directoriesAndFilename = explode('/', $filename);
        $filename = array_pop($directoriesAndFilename);
        $nameAndExtension = explode('.', $filename);
        $className = array_shift($nameAndExtension);

        return $className;
    }
1361363
public function fetchName(string $filename): ?string
    {
        return str_replace('\\', '/', substr($filename, 0, -1 * (1 + strlen($this->extension))));
    }
1108886
public function rm($filename)
    {
        $result = $this->client
            ->deleteObject(array(
                'Bucket' => $this->name,
                'Key'    => $filename
            ));

        return $result;
    }
623748
private function sanitize($filename)
    {
        $filename = preg_replace('/[^A-Za-z0-9\-\._]/', '.', (string) $filename);
        return trim(substr(preg_replace('/[_\.\-]{2,}/', '.', $filename), 0, 40), '._-');
    }
888266
public static function safeFilename($filename)
    {
        Deprecated::method(3.0);

        $filename = rawurlencode($filename); // Use 'rawurlencode', because we prefer '%20' over '+' for spaces.
        $filename = str_replace('%2F', '/', $filename);

        if (substr($filename, 0, 1) == '/') {
            $filename = substr($filename, 1);
        }

        return $filename;
    }
62500
public static function secureFileName($fileName)
    {
      $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
      $fileName = str_replace(array(":", "*", "?", "|", "/"), "_", $fileName);
      if ( $_config->getDisallowUnsafeCharacters() )
      {
        $fileName = str_replace(";", "_", $fileName);
      }
      if ($_config->forceAscii())
      {
        $fileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($fileName);
      }
      return $fileName;
    }