WordPress.org

Ready to get started?Download WordPress

Forums

Install via URL
Issue caused by forcing the file extension in the URL to be .ZIP (4 posts)

  1. Maor Chasen
    Member
    Posted 1 year ago #

    Hi.

    I really like the idea of this plugin. It's brilliant. And it really saves me time!

    A little problem I have with this plugin is that often times I need to install a plugin straight from Github. Well, the issue is that Github gives you a link to download a zip which look pretty much like this one:

    https://github.com/Automattic/push-syndication/zipball/master

    Notice there is no .ZIP extension at the end. So when I enter this URL, I get an error that only .ZIP files are accepted. But the funny thing is, that this is a ZIP file! But I know, there is no easy way to figure that out from the URL.

    I do have a suggestion though. You could take any URL that the user inputs and try to fetch only the headers. If it's a ZIP file, there will be a MIME-Type header that is equal to application/zip or some similar variation (some more options for this MIME value). Then if the MIME type is of a different file type, let the user know that only ZIP files are allowed.

    I would love to help with this issue and contribute!
    Please let me know what you think of this issue.
    After all the plugin is great and this is the only downside of it. By fixing this issue it can be perfect!

    Thanks for reading!
    M. Chasen

    http://wordpress.org/extend/plugins/upload-theme-via-url/

  2. Zagal
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,
    nice thought, actually it took me 5mins to solve the problem, because php5 offers finfo object. I did it like that:

    1. First I've changed compareExt function to this:

    function compareExt($url) {
    		//get file extension from url
    		$extension = self::getMime($url);
    		//check if mime headers = application/zip
    		if($extension == 'application/zip'):
    			return true;
    		else:
    			return false;
    		endif;
    	}

    2. Than I've added getMime function, which uses finfo_buffer to get mime headers.

    function getMime($url) {
    		//get file from url
    		$file = file_get_contents($url);
    		//create finfo object with FILEINFO_MIME_TYPE as argument
    		$finfoObject = new finfo(FILEINFO_MIME_TYPE);
    		//return mime header
    		return $finfoObject->buffer($file);
    	}

    I'll update the code as soon as possible. Thanks for an IDEA! :)

    Best regards,
    Zagal

  3. Maor Chasen
    Member
    Posted 1 year ago #

    Those are great news!

    Thanks for implementing that! I'll be testing it real soon, I'll try to let you know if it works for me too.

    Thanks again!

  4. Zagal
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,
    today I'll code some functions allowing plugin to support some other archive extensions.

    best regards,
    Zagal

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.