diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-10-23 00:55:59 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-10-23 00:55:59 +0000 |
commit | 2d1634134d7edd0554757d4180490e838e6001a4 (patch) | |
tree | a4b130e87f63894c1bd1f30011ce6d0c48102b58 /includes | |
parent | 566586a698c6712cdf95ee42983df77420fcc622 (diff) | |
download | brdo-2d1634134d7edd0554757d4180490e838e6001a4.tar.gz brdo-2d1634134d7edd0554757d4180490e838e6001a4.tar.bz2 |
- Patch #604618 by Crell, JacobSingh, axyjo: improve error handling of archiver.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/includes/common.inc b/includes/common.inc index a8964a630..428580a2c 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -6065,12 +6065,18 @@ function archiver_get_info() { * * @param $file * The full path of the archive file. Note that stream wrapper - * paths are supported. + * paths are supported, but not remote ones. * @return * A newly created instance of the archiver class appropriate * for the specified file, already bound to that file. + * If no appropriate archiver class was found, will return FALSE. */ function archiver_get_archiver($file) { + // Archivers can only work on local paths + $filepath = drupal_realpath($file); + if (!is_file($filepath)) { + throw new Exception(t('Archivers can only operate on local files: %file not supported', array('%file' => $file))); + } $archiver_info = archiver_get_info(); foreach ($archiver_info as $implementation) { @@ -6080,8 +6086,8 @@ function archiver_get_archiver($file) { // This method isn't quite as clean but gets the job done. // Also note that the file may not yet exist, so we cannot rely // on fileinfo() or other disk-level utilities. - if (strrpos($file, '.' . $extension) === strlen($file) - strlen('.' . $extension)) { - return new $implementation['class']($file); + if (strrpos($filepath, '.' . $extension) === strlen($filepath) - strlen('.' . $extension)) { + return new $implementation['class']($filepath); } } } |