public function sanitizeOnUploadPreSave(&$path, &$name, $src, $elfinder, $volume)
    {
        // To please PHPCS
        unset($path, $src, $elfinder, $volume);

        if (isset($this->elfinderOptions['plugin']['Sanitizer'])) {
            $opts = $this->elfinderOptions['plugin']['Sanitizer'];

            if (isset($opts['enable']) && $opts['enable']) {
                $mask = (is_array($opts['replace']) ? implode($opts['replace']) : $opts['replace']);
                $ext = '.'.pathinfo($name, PATHINFO_EXTENSION);

                // Strip leading and trailing dashes or underscores
                $name = trim(str_replace($ext, '', $name), $mask);

                // Squeeze multiple delimiters and whitespace with a single separator
                $name = preg_replace('!['.preg_quote($mask, '!').'\.\s]{2,}!', $opts['replace'], $name);

                // Reassemble the file name
                $name .= $ext;
            }
        }

        return true;
    }