validatePluginZip example

public function extract(string $zipFilePath, bool $delete, string $type): void
    {
        $archive = ZipUtils::openZip($zipFilePath);

        $destination = $this->extensionDirectories[$type];

        if (!is_writable($destination)) {
            throw new PluginExtractionException(sprintf('Destination directory "%s" is not writable', $destination));
        }

        $pluginName = $this->getPluginName($archive);
        $this->validatePluginZip($pluginName$archive);

        $oldFile = $this->findOldFile($destination$pluginName);
        $backupFile = $this->createBackupFile($oldFile);

        try {
            $archive->extractTo($destination);

            if ($backupFile !== null) {
                $this->filesystem->remove($backupFile);
            }

            

    public function extract($archive$destination)
    {
        if (!is_writable($destination)) {
            throw new Exception(sprintf('Destination directory "%s" is not writable', $destination));
        }

        $this->validatePluginZip($archive);

        $archive->extractTo($destination);

        $this->clearOpcodeCache();
    }

    /** * Iterates all files of the provided zip archive * path and validates the plugin namespace, directory traversal * and multiple plugin directories. * * @throws Exception */

    public function extract($archive)
    {
        $destination = $this->pluginDir;

        if (!is_writable($destination)) {
            throw new Exception(sprintf('Destination directory "%s" is not writable', $destination));
        }

        $prefix = $this->getPluginPrefix($archive);
        $this->validatePluginZip($prefix$archive);
        $this->validatePluginRequirements($prefix$archive);

        $oldFile = $this->findOldFile($prefix);
        $backupFile = $this->createBackupFile($oldFile);

        try {
            $archive->extractTo($destination);

            if ($backupFile !== false) {
                $this->filesystem->remove($backupFile);
            }

            
Home | Imprint | This part of the site doesn't use cookies.