diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-01-21 13:50:56 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-01-21 13:50:56 +0100 |
commit | 37e278f2a90bd460668e840775dd741b85eca022 (patch) | |
tree | 6543c49853ac551867cbd01e6a37860e8343a063 /apps/files_versions | |
parent | 2e7fed1b9b631703ebefb6f7586d9e01b327eadd (diff) | |
download | nextcloud-server-37e278f2a90bd460668e840775dd741b85eca022.tar.gz nextcloud-server-37e278f2a90bd460668e840775dd741b85eca022.zip |
don't use the user id within the versions preview call as it could be used to access previews of another user
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/ajax/getVersions.php | 2 | ||||
-rw-r--r-- | apps/files_versions/ajax/preview.php | 10 | ||||
-rw-r--r-- | apps/files_versions/lib/versions.php | 17 |
3 files changed, 14 insertions, 15 deletions
diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 4f48f71d8ca..df29f401629 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -5,7 +5,7 @@ $source = $_GET['source']; $start = $_GET['start']; list ($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source); $count = 5; //show the newest revisions -if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename)) ) { +if( ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source)) ) { $endReached = false; if (count($versions) <= $start+$count) { diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php index 31525028ef3..bd9b7366ab0 100644 --- a/apps/files_versions/ajax/preview.php +++ b/apps/files_versions/ajax/preview.php @@ -12,18 +12,11 @@ if(!\OC_App::isEnabled('files_versions')){ } $file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; -$user = array_key_exists('user', $_GET) ? $_GET['user'] : ''; $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : 44; $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : 44; $version = array_key_exists('version', $_GET) ? $_GET['version'] : ''; $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; -if($user === '') { - \OC_Response::setStatus(400); //400 Bad Request - \OC_Log::write('versions-preview', 'No user parameter was passed', \OC_Log::DEBUG); - exit; -} - if($file === '' && $version === '') { \OC_Response::setStatus(400); //400 Bad Request \OC_Log::write('versions-preview', 'No file parameter was passed', \OC_Log::DEBUG); @@ -36,7 +29,8 @@ if($maxX === 0 || $maxY === 0) { exit; } -try{ +try { + list($user, $file) = \OCA\Files_Versions\Storage::getUidAndFilename($file); $preview = new \OC\Preview($user, 'files_versions', $file.'.v'.$version); $mimetype = \OC_Helper::getFileNameMimeType($file); $preview->setMimetype($mimetype); diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index f268fa10b66..01c2e1ccdee 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -261,11 +261,12 @@ class Storage { /** * @brief get a list of all available versions of a file in descending chronological order - * @param $uid user id from the owner of the file - * @param $filename file to find versions of, relative to the user files dir + * @param string $uid user id from the owner of the file + * @param string $filename file to find versions of, relative to the user files dir + * @param string $userFullPath * @returns array */ - public static function getVersions($uid, $filename) { + public static function getVersions($uid, $filename, $userFullPath = '') { $versions = array(); // fetch for old versions $view = new \OC\Files\View('/' . $uid . '/' . self::VERSIONS_ROOT); @@ -286,7 +287,11 @@ class Storage { $versions[$key]['cur'] = 0; $versions[$key]['version'] = $version; $versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version); - $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $filename, 'version' => $version, 'user' => $uid)); + if (empty($userFullPath)) { + $versions[$key]['preview'] = ''; + } else { + $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $userFullPath, 'version' => $version)); + } $versions[$key]['path'] = $filename; $versions[$key]['name'] = $versionedFile; $versions[$key]['size'] = $file['size']; @@ -508,8 +513,8 @@ class Storage { * @brief delete old version from a given list of versions * * @param array $versionsByFile list of versions ordered by files - * @param array $allVversions all versions accross multiple files - * @param $versionsFileview OC\Files\View on data/user/files_versions + * @param array $allVversions all versions across multiple files + * @param $versionsFileview \OC\Files\View on data/user/files_versions * @return size of releted versions */ private static function delOldVersions($versionsByFile, &$allVersions, $versionsFileview) { |