diff options
Diffstat (limited to 'lib/plugins/extension')
-rw-r--r-- | lib/plugins/extension/helper/extension.php | 12 | ||||
-rw-r--r-- | lib/plugins/extension/lang/en/lang.php | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php index c13aa983d..7958cd2da 100644 --- a/lib/plugins/extension/helper/extension.php +++ b/lib/plugins/extension/helper/extension.php @@ -783,11 +783,17 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin { */ public function download($url) { // check the url - $matches = array(); - if(!preg_match('/[^\/]*$/', $url, $matches) || !$matches[0]) { + if(!preg_match('/https?:\/\//i', $url)){ throw new Exception($this->getLang('error_badurl')); } - $file = $matches[0]; + + // try to get the file from the path (used as plugin name fallback) + $file = parse_url($url, PHP_URL_PATH); + if(is_null($file)){ + $file = md5($url); + }else{ + $file = utf8_basename($file); + } // create tmp directory for download if(!($tmp = $this->mkTmpDir())) { diff --git a/lib/plugins/extension/lang/en/lang.php b/lib/plugins/extension/lang/en/lang.php index 06c83a708..b11490c0c 100644 --- a/lib/plugins/extension/lang/en/lang.php +++ b/lib/plugins/extension/lang/en/lang.php @@ -82,7 +82,7 @@ $lang['update_available'] = '<strong>Update:</strong> New version %s $lang['wrong_folder'] = '<strong>Plugin installed incorrectly:</strong> Rename plugin directory "%s" to "%s".'; $lang['url_change'] = '<strong>URL changed:</strong> Download URL has changed since last download. Check if the new URL is valid before updating the extension.<br />New: %s<br />Old: %s'; -$lang['error_badurl'] = 'URL ends with slash - unable to determine file name from the url'; +$lang['error_badurl'] = 'URLs should start with http or https'; $lang['error_dircreate'] = 'Unable to create temporary folder to receive download'; $lang['error_download'] = 'Unable to download the file: %s'; $lang['error_decompress'] = 'Unable to decompress the downloaded file. This maybe as a result of a bad download, in which case you should try again; or the compression format may be unknown, in which case you will need to download and install manually.'; |