diff options
-rw-r--r-- | apps/files/js/filelist.js | 2 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 2 | ||||
-rw-r--r-- | apps/files_encryption/hooks/hooks.php | 33 | ||||
-rw-r--r-- | apps/files_encryption/lib/util.php | 203 | ||||
-rw-r--r-- | apps/files_encryption/tests/helper.php | 9 | ||||
-rwxr-xr-x | apps/files_encryption/tests/util.php | 12 | ||||
-rw-r--r-- | apps/user_ldap/appinfo/update.php | 42 | ||||
-rw-r--r-- | apps/user_ldap/appinfo/version | 2 | ||||
-rw-r--r-- | apps/user_ldap/js/settings.js | 2 | ||||
-rw-r--r-- | apps/user_ldap/templates/part.settingcontrols.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/templates/part.wizardcontrols.php | 2 | ||||
-rwxr-xr-x | apps/user_webdavauth/templates/settings.php | 4 | ||||
-rw-r--r-- | core/js/js.js | 12 | ||||
-rw-r--r-- | core/js/share.js | 44 | ||||
-rw-r--r-- | core/js/tests/specs/coreSpec.js | 24 | ||||
-rw-r--r-- | core/templates/login.php | 3 | ||||
-rw-r--r-- | db_structure.xml | 27 | ||||
-rw-r--r-- | lib/base.php | 10 | ||||
-rw-r--r-- | lib/private/user.php | 2 | ||||
-rw-r--r-- | settings/js/admin.js | 3 | ||||
-rw-r--r-- | settings/templates/admin.php | 18 |
21 files changed, 257 insertions, 201 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 1b2a62137e5..4229988b171 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -613,7 +613,7 @@ // size column if (typeof(fileData.size) !== 'undefined' && fileData.size >= 0) { - simpleSize = humanFileSize(parseInt(fileData.size, 10)); + simpleSize = humanFileSize(parseInt(fileData.size, 10), true); sizeColor = Math.round(160-Math.pow((fileData.size/(1024*1024)),2)); } else { simpleSize = t('files', 'Pending'); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 855a5c9af51..7d3bc946dd3 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -252,7 +252,7 @@ describe('OCA.Files.FileList tests', function() { size: '0' }; var $tr = fileList.add(fileData); - expect($tr.find('.filesize').text()).toEqual('0 B'); + expect($tr.find('.filesize').text()).toEqual('0 kB'); }); it('adds new file to the end of the list', function() { var $tr; diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index f2096c3956e..8fae901fe63 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -51,16 +51,16 @@ class Hooks { $view = new \OC\Files\View('/');
// ensure filesystem is loaded
- if(!\OC\Files\Filesystem::$loaded) {
+ if (!\OC\Files\Filesystem::$loaded) {
\OC_Util::setupFS($params['uid']);
}
$privateKey = \OCA\Encryption\Keymanager::getPrivateKey($view, $params['uid']);
// if no private key exists, check server configuration
- if(!$privateKey) {
+ if (!$privateKey) {
//check if all requirements are met
- if(!Helper::checkRequirements() || !Helper::checkConfiguration()) {
+ if (!Helper::checkRequirements() || !Helper::checkConfiguration()) {
$error_msg = $l->t("Missing requirements.");
$hint = $l->t('Please make sure that PHP 5.3.3 or newer is installed and that OpenSSL together with the PHP extension is enabled and configured properly. For now, the encryption app has been disabled.');
\OC_App::disable('files_encryption');
@@ -90,6 +90,8 @@ class Hooks { return false;
}
+ $result = true;
+
// If migration not yet done
if ($ready) {
@@ -97,15 +99,12 @@ class Hooks { // Set legacy encryption key if it exists, to support
// depreciated encryption system
- if (
- $userView->file_exists('encryption.key')
- && $encLegacyKey = $userView->file_get_contents('encryption.key')
- ) {
+ $encLegacyKey = $userView->file_get_contents('encryption.key');
+ if ($encLegacyKey) {
$plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']);
$session->setLegacyKey($plainLegacyKey);
-
}
// Encrypt existing user files
@@ -113,26 +112,24 @@ class Hooks { $result = $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password']);
} catch (\Exception $ex) {
\OCP\Util::writeLog('Encryption library', 'Initial encryption failed! Error: ' . $ex->getMessage(), \OCP\Util::FATAL);
- $util->resetMigrationStatus();
- \OCP\User::logout();
$result = false;
}
if ($result) {
-
\OC_Log::write(
- 'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed'
- , \OC_Log::INFO
- );
-
+ 'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed'
+ , \OC_Log::INFO
+ );
// Register successful migration in DB
$util->finishMigration();
-
+ } else {
+ \OCP\Util::writeLog('Encryption library', 'Initial encryption failed!', \OCP\Util::FATAL);
+ $util->resetMigrationStatus();
+ \OCP\User::logout();
}
}
- return true;
-
+ return $result;
}
/**
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 991960b7fa9..434d23f4a5a 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -303,7 +303,7 @@ class Util { * Find all files and their encryption status within a directory * @param string $directory The path of the parent directory to search * @param bool $found the founded files if called again - * @return mixed false if 0 found, array on success. Keys: name, path + * @return array keys: plain, encrypted, legacy, broken * @note $directory needs to be a path relative to OC data dir. e.g. * /admin/files NOT /backup OR /home/www/oc/data/admin/files */ @@ -322,11 +322,8 @@ class Util { ); } - if ( - $this->view->is_dir($directory) - && $handle = $this->view->opendir($directory) - ) { - if(is_resource($handle)) { + if ($this->view->is_dir($directory) && $handle = $this->view->opendir($directory)){ + if (is_resource($handle)) { while (false !== ($file = readdir($handle))) { if ($file !== "." && $file !== "..") { @@ -390,34 +387,16 @@ class Util { 'name' => $file, 'path' => $relPath ); - } - } - } - } } - - \OC_FileProxy::$enabled = true; - - if (empty($found)) { - - return false; - - } else { - - return $found; - - } - } \OC_FileProxy::$enabled = true; - return false; - + return $found; } /** @@ -571,28 +550,6 @@ class Util { return $result; } - - /** - * @param string $path - * @return bool - */ - public function isSharedPath($path) { - - $trimmed = ltrim($path, '/'); - $split = explode('/', $trimmed); - - if (isset($split[2]) && $split[2] === 'Shared') { - - return true; - - } else { - - return false; - - } - - } - /** * encrypt versions from given file * @param array $filelist list of encrypted files, relative to data/user/files @@ -808,121 +765,119 @@ class Util { */ public function encryptAll($dirPath, $legacyPassphrase = null, $newPassphrase = null) { + $result = true; + $found = $this->findEncFiles($dirPath); - if ($found) { + // Disable proxy to prevent file being encrypted twice + \OC_FileProxy::$enabled = false; - // Disable proxy to prevent file being encrypted twice - \OC_FileProxy::$enabled = false; + $versionStatus = \OCP\App::isEnabled('files_versions'); + \OC_App::disable('files_versions'); - $versionStatus = \OCP\App::isEnabled('files_versions'); - \OC_App::disable('files_versions'); + $encryptedFiles = array(); - $encryptedFiles = array(); + // Encrypt unencrypted files + foreach ($found['plain'] as $plainFile) { - // Encrypt unencrypted files - foreach ($found['plain'] as $plainFile) { + //get file info + $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']); - //get file info - $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']); + //relative to data/<user>/file + $relPath = $plainFile['path']; - //relative to data/<user>/file - $relPath = $plainFile['path']; + //relative to /data + $rawPath = '/' . $this->userId . '/files/' . $plainFile['path']; - //relative to /data - $rawPath = '/' . $this->userId . '/files/' . $plainFile['path']; - - // keep timestamp - $timestamp = $fileInfo['mtime']; + // keep timestamp + $timestamp = $fileInfo['mtime']; - // Open plain file handle for binary reading - $plainHandle = $this->view->fopen($rawPath, 'rb'); + // Open plain file handle for binary reading + $plainHandle = $this->view->fopen($rawPath, 'rb'); - // Open enc file handle for binary writing, with same filename as original plain file - $encHandle = fopen('crypt://' . $rawPath . '.part', 'wb'); + // Open enc file handle for binary writing, with same filename as original plain file + $encHandle = fopen('crypt://' . $rawPath . '.part', 'wb'); - if (is_resource($encHandle)) { - // Move plain file to a temporary location - $size = stream_copy_to_stream($plainHandle, $encHandle); + if (is_resource($encHandle) && is_resource($plainHandle)) { + // Move plain file to a temporary location + $size = stream_copy_to_stream($plainHandle, $encHandle); - fclose($encHandle); - fclose($plainHandle); + fclose($encHandle); + fclose($plainHandle); - $fakeRoot = $this->view->getRoot(); - $this->view->chroot('/' . $this->userId . '/files'); + $fakeRoot = $this->view->getRoot(); + $this->view->chroot('/' . $this->userId . '/files'); - $this->view->rename($relPath . '.part', $relPath); + $this->view->rename($relPath . '.part', $relPath); - // set timestamp - $this->view->touch($relPath, $timestamp); + // set timestamp + $this->view->touch($relPath, $timestamp); - $encSize = $this->view->filesize($relPath); + $encSize = $this->view->filesize($relPath); - $this->view->chroot($fakeRoot); + $this->view->chroot($fakeRoot); - // Add the file to the cache - \OC\Files\Filesystem::putFileInfo($relPath, array( - 'encrypted' => true, - 'size' => $encSize, - 'unencrypted_size' => $size, - 'etag' => $fileInfo['etag'] - )); + // Add the file to the cache + \OC\Files\Filesystem::putFileInfo($relPath, array( + 'encrypted' => true, + 'size' => $encSize, + 'unencrypted_size' => $size, + 'etag' => $fileInfo['etag'] + )); - $encryptedFiles[] = $relPath; - } + $encryptedFiles[] = $relPath; + } else { + \OCP\Util::writeLog('files_encryption', 'initial encryption: could not encrypt ' . $rawPath, \OCP\Util::FATAL); + $result = false; } + } - // Encrypt legacy encrypted files - if ( - !empty($legacyPassphrase) - && !empty($newPassphrase) - ) { - - foreach ($found['legacy'] as $legacyFile) { + // Encrypt legacy encrypted files + if (!empty($legacyPassphrase) && !empty($newPassphrase)) { - // Fetch data from file - $legacyData = $this->view->file_get_contents($legacyFile['path']); + foreach ($found['legacy'] as $legacyFile) { - // decrypt data, generate catfile - $decrypted = Crypt::legacyBlockDecrypt($legacyData, $legacyPassphrase); + // Fetch data from file + $legacyData = $this->view->file_get_contents($legacyFile['path']); - $rawPath = $legacyFile['path']; + // decrypt data, generate catfile + $decrypted = Crypt::legacyBlockDecrypt($legacyData, $legacyPassphrase); - // enable proxy the ensure encryption is handled - \OC_FileProxy::$enabled = true; + $rawPath = $legacyFile['path']; - // Open enc file handle for binary writing, with same filename as original plain file - $encHandle = $this->view->fopen( $rawPath, 'wb' ); + // enable proxy the ensure encryption is handled + \OC_FileProxy::$enabled = true; - if (is_resource($encHandle)) { + // Open enc file handle for binary writing, with same filename as original plain file + $encHandle = $this->view->fopen($rawPath, 'wb'); - // write data to stream - fwrite($encHandle, $decrypted); + if (is_resource($encHandle)) { - // close stream - fclose($encHandle); - } + // write data to stream + fwrite($encHandle, $decrypted); - // disable proxy to prevent file being encrypted twice - \OC_FileProxy::$enabled = false; + // close stream + fclose($encHandle); + } else { + \OCP\Util::writeLog('files_encryption', 'initial encryption: could not encrypt legacy file ' . $rawPath, \OCP\Util::FATAL); + $result = false; } + + // disable proxy to prevent file being encrypted twice + \OC_FileProxy::$enabled = false; } + } - \OC_FileProxy::$enabled = true; + \OC_FileProxy::$enabled = true; - if ($versionStatus) { - \OC_App::enable('files_versions'); - } + if ($versionStatus) { + \OC_App::enable('files_versions'); + } - $this->encryptVersions($encryptedFiles); + $result = $result && $this->encryptVersions($encryptedFiles); - // If files were found, return true - return true; - } else { + return $result; - // If no files were found, return false - return false; - } } /** diff --git a/apps/files_encryption/tests/helper.php b/apps/files_encryption/tests/helper.php index 4b46e976b81..582d8149a8a 100644 --- a/apps/files_encryption/tests/helper.php +++ b/apps/files_encryption/tests/helper.php @@ -18,15 +18,20 @@ use OCA\Encryption; class Test_Encryption_Helper extends \PHPUnit_Framework_TestCase { const TEST_ENCRYPTION_HELPER_USER1 = "test-helper-user1"; + const TEST_ENCRYPTION_HELPER_USER2 = "test-helper-user2"; public static function setUpBeforeClass() { // create test user + \Test_Encryption_Util::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2, true); \Test_Encryption_Util::loginHelper(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1, true); } public static function tearDownAfterClass() { // cleanup test user \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1); + \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2); + \OC_Hook::clear(); + \OC_FileProxy::clearProxies(); } /** @@ -81,9 +86,11 @@ class Test_Encryption_Helper extends \PHPUnit_Framework_TestCase { $path1 = "/" . self::TEST_ENCRYPTION_HELPER_USER1 . "/files/foo/bar.txt"; $path2 = "/" . self::TEST_ENCRYPTION_HELPER_USER1 . "/cache/foo/bar.txt"; - $path3 = "/" . self::TEST_ENCRYPTION_HELPER_USER1 . "/thumbnails/foo"; + $path3 = "/" . self::TEST_ENCRYPTION_HELPER_USER2 . "/thumbnails/foo"; $path4 ="/" . "/" . self::TEST_ENCRYPTION_HELPER_USER1; + \Test_Encryption_Util::loginHelper(self::TEST_ENCRYPTION_HELPER_USER1); + // if we are logged-in every path should return the currently logged-in user $this->assertEquals(self::TEST_ENCRYPTION_HELPER_USER1, Encryption\Helper::getUser($path3)); diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php index a4dcc5cc8bd..2b873bb308d 100755 --- a/apps/files_encryption/tests/util.php +++ b/apps/files_encryption/tests/util.php @@ -306,18 +306,6 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { $this->view->unlink($this->userId . '/files/' . $filename); } - /** - * @medium - */ - function testIsSharedPath() { - $sharedPath = '/user1/files/Shared/test'; - $path = '/user1/files/test'; - - $this->assertTrue($this->util->isSharedPath($sharedPath)); - - $this->assertFalse($this->util->isSharedPath($path)); - } - function testEncryptAll() { $filename = "/encryptAll" . uniqid() . ".txt"; diff --git a/apps/user_ldap/appinfo/update.php b/apps/user_ldap/appinfo/update.php index 41770cf97b1..1e706ce869b 100644 --- a/apps/user_ldap/appinfo/update.php +++ b/apps/user_ldap/appinfo/update.php @@ -7,21 +7,39 @@ if($state === 'unset') { OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); } +$installedVersion = OCP\Config::getAppValue('user_ldap', 'installed_version'); +$enableRawMode = version_compare($installedVersion, '0.4.1', '<'); + $configPrefixes = OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes(true); $ldap = new OCA\user_ldap\lib\LDAP(); foreach($configPrefixes as $config) { $connection = new OCA\user_ldap\lib\Connection($ldap, $config); - $value = \OCP\Config::getAppValue('user_ldap', - $config.'ldap_uuid_attribute', 'auto'); - \OCP\Config::setAppValue('user_ldap', - $config.'ldap_uuid_user_attribute', $value); - \OCP\Config::setAppValue('user_ldap', - $config.'ldap_uuid_group_attribute', $value); - $value = \OCP\Config::getAppValue('user_ldap', - $config.'ldap_expert_uuid_attr', 'auto'); - \OCP\Config::setAppValue('user_ldap', - $config.'ldap_expert_uuid_user_attr', $value); - \OCP\Config::setAppValue('user_ldap', - $config.'ldap_expert_uuid_group_attr', $value); + $state = \OCP\Config::getAppValue( + 'user_ldap', $config.'ldap_uuid_user_attribute', 'not existing'); + if($state === 'non existing') { + $value = \OCP\Config::getAppValue( + 'user_ldap', $config.'ldap_uuid_attribute', 'auto'); + \OCP\Config::setAppValue( + 'user_ldap', $config.'ldap_uuid_user_attribute', $value); + \OCP\Config::setAppValue( + 'user_ldap', $config.'ldap_uuid_group_attribute', $value); + } + + $state = \OCP\Config::getAppValue( + 'user_ldap', $config.'ldap_expert_uuid_user_attr', 'not existing'); + if($state === 'non existing') { + $value = \OCP\Config::getAppValue( + 'user_ldap', $config.'ldap_expert_uuid_attr', 'auto'); + \OCP\Config::setAppValue( + 'user_ldap', $config.'ldap_expert_uuid_user_attr', $value); + \OCP\Config::setAppValue( + 'user_ldap', $config.'ldap_expert_uuid_group_attr', $value); + } + + if($enableRawMode) { + \OCP\Config::setAppValue('user_ldap', $config.'ldap_user_filter_mode', 1); + \OCP\Config::setAppValue('user_ldap', $config.'ldap_login_filter_mode', 1); + \OCP\Config::setAppValue('user_ldap', $config.'ldap_group_filter_mode', 1); + } } diff --git a/apps/user_ldap/appinfo/version b/apps/user_ldap/appinfo/version index 44bb5d1f743..2b7c5ae0184 100644 --- a/apps/user_ldap/appinfo/version +++ b/apps/user_ldap/appinfo/version @@ -1 +1 @@ -0.4.1
\ No newline at end of file +0.4.2 diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index 8c18cc4c58c..87d755697cb 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -90,7 +90,7 @@ var LdapConfiguration = { ); } $('#ldap_serverconfig_chooser option:selected').removeAttr('selected'); - var html = '<option value="'+result.configPrefix+'" selected="selected">'+t('user_ldap','{nbServer}. Server', {nbServer: $('#ldap_serverconfig_chooser option').length})+'</option>'; + var html = '<option value="'+result.configPrefix+'" selected="selected">'+t('user_ldap','{nthServer}. Server', {nthServer: $('#ldap_serverconfig_chooser option').length})+'</option>'; $('#ldap_serverconfig_chooser option:last').before(html); LdapWizard.init(); } else { diff --git a/apps/user_ldap/templates/part.settingcontrols.php b/apps/user_ldap/templates/part.settingcontrols.php index dfc49549032..ddf65e8a754 100644 --- a/apps/user_ldap/templates/part.settingcontrols.php +++ b/apps/user_ldap/templates/part.settingcontrols.php @@ -3,7 +3,7 @@ <button class="ldap_action_test_connection" name="ldap_action_test_connection"> <?php p($l->t('Test Configuration'));?> </button> - <a href="<?php p($theme->getDocBaseUrl()); ?>/server/7.0/admin_manual/configuration/auth_ldap.html" + <a href="<?php p(\OC_Helper::linkToDocs('admin-ldap')); ?>" target="_blank"> <img src="<?php print_unescaped(OCP\Util::imagePath('', 'actions/info.png')); ?>" style="height:1.75ex" /> diff --git a/apps/user_ldap/templates/part.wizardcontrols.php b/apps/user_ldap/templates/part.wizardcontrols.php index 862e10bdd12..33e1614c9c6 100644 --- a/apps/user_ldap/templates/part.wizardcontrols.php +++ b/apps/user_ldap/templates/part.wizardcontrols.php @@ -7,7 +7,7 @@ <button class="ldap_action_continue" name="ldap_action_continue" type="button"> <?php p($l->t('Continue'));?> </button> - <a href="<?php p($theme->getDocBaseUrl()); ?>/server/7.0/admin_manual/configuration/auth_ldap.html" + <a href="<?php p(\OC_Helper::linkToDocs('admin-ldap')); ?>" target="_blank"> <img src="<?php print_unescaped(OCP\Util::imagePath('', 'actions/info.png')); ?>" style="height:1.75ex" /> diff --git a/apps/user_webdavauth/templates/settings.php b/apps/user_webdavauth/templates/settings.php index 4596fdf3c78..a87c0ad159a 100755 --- a/apps/user_webdavauth/templates/settings.php +++ b/apps/user_webdavauth/templates/settings.php @@ -1,7 +1,7 @@ <form id="webdavauth" class="section" action="#" method="post"> <h2><?php p($l->t('WebDAV Authentication'));?></h2> - <p><label for="webdav_url"><?php p($l->t('Address: '));?><input type="url" placeholder="https://example.com/webdav" id="webdav_url" name="webdav_url" value="<?php p($_['webdav_url']); ?>"></label> + <p><label for="webdav_url"><?php p($l->t('Address:').' ');?><input type="url" placeholder="https://example.com/webdav" id="webdav_url" name="webdav_url" value="<?php p($_['webdav_url']); ?>"></label> <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" id="requesttoken"> - <input type="submit" value="Save" /> + <input type="submit" value="<?php p($l->t('Save')); ?>" /> <br /><?php p($l->t('The user credentials will be sent to this address. This plugin checks the response and will interpret the HTTP statuscodes 401 and 403 as invalid credentials, and all other responses as valid credentials.')); ?> </form> diff --git a/core/js/js.js b/core/js/js.js index cf35d8aac6a..a859034ed01 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -154,7 +154,7 @@ function n(app, text_singular, text_plural, count, vars) { * @return {string} Sanitized string */ function escapeHTML(s) { - return s.toString().split('&').join('&').split('<').join('<').split('"').join('"'); + return s.toString().split('&').join('&').split('<').join('<').split('>').join('>').split('"').join('"').split('\'').join('''); } /** @@ -1163,9 +1163,10 @@ $.fn.filterAttr = function(attr_name, attr_value) { /** * Returns a human readable file size * @param {number} size Size in bytes + * @param {boolean} skipSmallSizes return '< 1 kB' for small files * @return {string} */ -function humanFileSize(size) { +function humanFileSize(size, skipSmallSizes) { var humanList = ['B', 'kB', 'MB', 'GB', 'TB']; // Calculate Log with base 1024: size = 1024 ** order var order = size?Math.floor(Math.log(size) / Math.log(1024)):0; @@ -1173,6 +1174,13 @@ function humanFileSize(size) { order = Math.min(humanList.length - 1, order); var readableFormat = humanList[order]; var relativeSize = (size / Math.pow(1024, order)).toFixed(1); + if(skipSmallSizes === true && order === 0) { + if(relativeSize !== "0.0"){ + return '< 1 kB'; + } else { + return '0 kB'; + } + } if(order < 2){ relativeSize = parseFloat(relativeSize).toFixed(0); } diff --git a/core/js/share.js b/core/js/share.js index 90f6c7fdc7c..0c6d39e446c 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -48,23 +48,26 @@ OC.Share={ currentDir = fileList.getCurrentDirectory(); } for (item in OC.Share.statuses){ - var image; + var image = OC.imagePath('core', 'actions/shared'); var data = OC.Share.statuses[item]; - var hasLink = data.link; // Links override shared in terms of icon display if (hasLink) { image = OC.imagePath('core', 'actions/public'); - } else { - image = OC.imagePath('core', 'actions/shared'); } if (itemType !== 'file' && itemType !== 'folder') { $fileList.find('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center'); } else { var file = $fileList.find('tr[data-id="'+item+'"]'); + var shareFolder = OC.imagePath('core', 'filetypes/folder-shared'); + var img; if (file.length > 0) { + var type = file.data('type'); + if (type === 'dir') { + file.children('.filename').css('background-image', 'url('+shareFolder+')'); + } var action = $(file).find('.fileactions .action[data-action="Share"]'); - var img = action.find('img').attr('src', image); + img = action.find('img').attr('src', image); action.addClass('permanent'); action.html(' <span>'+t('core', 'Shared')+'</span>').prepend(img); } else { @@ -76,14 +79,21 @@ OC.Share={ while (path != last) { if (path === data.path && !data.link) { var actions = $fileList.find('.fileactions .action[data-action="Share"]'); - $.each(actions, function(index, action) { - var img = $(action).find('img'); + var files = $fileList.find('.filename'); + var i; + for (i = 0; i < actions.length; i++) { + img = $(actions[i]).find('img'); if (img.attr('src') !== OC.imagePath('core', 'actions/public')) { img.attr('src', image); - $(action).addClass('permanent'); - $(action).html(' <span>'+t('core', 'Shared')+'</span>').prepend(img); + $(actions[i]).addClass('permanent'); + $(actions[i]).html(' <span>'+t('core', 'Shared')+'</span>').prepend(img); + } + } + for(i = 0; i < files.length; i++) { + if ($(files[i]).closest('tr').data('type') === 'dir') { + $(files[i]).css('background-image', 'url('+shareFolder+')'); } - }); + } } last = path; path = OC.Share.dirname(path); @@ -117,6 +127,14 @@ OC.Share={ } else { var file = $('tr').filterAttr('data-id', String(itemSource)); if (file.length > 0) { + var type = file.data('type'); + var shareFolder = OC.imagePath('core', 'filetypes/folder'); + if (type === 'dir' && shares) { + shareFolder = OC.imagePath('core', 'filetypes/folder-shared'); + file.children('.filename').css('background-image', 'url('+shareFolder+')'); + } else if (type === 'dir') { + file.children('.filename').css('background-image', 'url('+shareFolder+')'); + } var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share'); // in case of multiple lists/rows, there might be more than one visible action.each(function() { @@ -517,10 +535,10 @@ OC.Share={ showLink:function(token, password, itemSource) { OC.Share.itemShares[OC.Share.SHARE_TYPE_LINK] = true; $('#linkCheckbox').attr('checked', true); - + //check itemType var linkSharetype=$('#dropdown').data('item-type'); - + if (! token) { //fallback to pre token link var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file'); @@ -540,7 +558,7 @@ OC.Share={ }else{ service=linkSharetype; } - + var link = parent.location.protocol+'//'+location.host+OC.linkTo('', 'public.php')+'?service='+service+'&t='+token; } diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 65f768fbc51..47e5ebfed55 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -124,6 +124,17 @@ describe('Core base tests', function() { expect(OC.dirname('/subdir/')).toEqual('/subdir'); }); }); + describe('escapeHTML', function() { + it('Returns nothing if no string was given', function() { + expect(escapeHTML('')).toEqual(''); + }); + it('Returns a sanitized string if a string containing HTML is given', function() { + expect(escapeHTML('There needs to be a <script>alert(\"Unit\" + \'test\')</script> for it!')).toEqual('There needs to be a <script>alert("Unit" + 'test')</script> for it!'); + }); + it('Returns the string without modification if no potentially dangerous character is passed.', function() { + expect(escapeHTML('This is a good string without HTML.')).toEqual('This is a good string without HTML.'); + }); + }); describe('Link functions', function() { var TESTAPP = 'testapp'; var TESTAPP_ROOT = OC.webroot + '/appsx/testapp'; @@ -489,6 +500,19 @@ describe('Core base tests', function() { expect(OC.Util.humanFileSize(data[i][0])).toEqual(data[i][1]); } }); + it('renders file sizes with the correct unit for small sizes', function() { + var data = [ + [0, '0 kB'], + [125, '< 1 kB'], + [128000, '125 kB'], + [128000000, '122.1 MB'], + [128000000000, '119.2 GB'], + [128000000000000, '116.4 TB'] + ]; + for (var i = 0; i < data.length; i++) { + expect(OC.Util.humanFileSize(data[i][0], true)).toEqual(data[i][1]); + } + }); }); }); }); diff --git a/core/templates/login.php b/core/templates/login.php index 669d20b32e4..0f25f853b02 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -1,3 +1,5 @@ +<?php /** @var $l OC_L10N */ ?> + <!--[if IE 8]><style>input[type="checkbox"]{padding:0;}</style><![endif]--> <form method="post" name="login"> <fieldset> @@ -51,6 +53,7 @@ <label for="remember_login"><?php p($l->t('remember')); ?></label> <?php endif; ?> <input type="hidden" name="timezone-offset" id="timezone-offset"/> + <input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" /> <input type="submit" id="submit" class="login primary" value="<?php p($l->t('Log in')); ?>" disabled="disabled"/> </fieldset> </form> diff --git a/db_structure.xml b/db_structure.xml index 21ac47a781b..ed4954c02b2 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -400,6 +400,21 @@ </field> </index> + <index> + <name>fs_storage_size</name> + <field> + <name>storage</name> + <sorting>ascending</sorting> + </field> + <field> + <name>size</name> + <sorting>ascending</sorting> + </field> + <field> + <name>fileid</name> + </field> + </index> + </declaration> </table> @@ -970,6 +985,18 @@ <sorting>ascending</sorting> </field> </index> + <index> + <name>file_target_index</name> + <field> + <name>file_target</name> + </field> + <field> + <name>uid_owner</name> + </field> + <field> + <name>share_type</name> + </field> + </index> </declaration> </table> diff --git a/lib/base.php b/lib/base.php index 882b587a6fd..5f2131f388f 100644 --- a/lib/base.php +++ b/lib/base.php @@ -765,11 +765,20 @@ class OC { return; } + // Redirect to index if the logout link is accessed without valid session + // this is needed to prevent "Token expired" messages while login if a session is expired + // @see https://github.com/owncloud/core/pull/8443#issuecomment-42425583 + if(isset($_GET['logout']) && !OC_User::isLoggedIn()) { + header("Location: " . OC::$WEBROOT.(empty(OC::$WEBROOT) ? '/' : '')); + return; + } + // Someone is logged in : if (OC_User::isLoggedIn()) { OC_App::loadApps(); OC_User::setupBackends(); if (isset($_GET["logout"]) and ($_GET["logout"])) { + OC_JSON::callCheck(); if (isset($_COOKIE['oc_token'])) { OC_Preferences::deleteKey(OC_User::getUser(), 'login_token', $_COOKIE['oc_token']); } @@ -930,6 +939,7 @@ class OC { return false; } + OC_JSON::callCheck(); OC_App::loadApps(); //setup extra user backends diff --git a/lib/private/user.php b/lib/private/user.php index 5d3ebb57c8c..a8431af97fd 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -365,7 +365,7 @@ class OC_User { return $backend->getLogoutAttribute(); } - return 'href="' . link_to('', 'index.php') . '?logout=true"'; + return 'href="' . link_to('', 'index.php') . '?logout=true&requesttoken=' . OC_Util::callRegister() . '"'; } /** diff --git a/settings/js/admin.js b/settings/js/admin.js index bc95c6a3dc5..8c7572fa394 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -83,6 +83,9 @@ $(document).ready(function(){ $('#allowLinks').change(function() { $("#publicLinkSettings").toggleClass('hidden', !this.checked); }); + $('#allowResharing').change(function() { + $("#resharingSettings").toggleClass('hidden', !this.checked); + }); $('#security').change(function(){ $.post(OC.filePath('settings','ajax','setsecurity.php'), { enforceHTTPS: $('#forcessl').val() },function(){} ); diff --git a/settings/templates/admin.php b/settings/templates/admin.php index a86fe9c0ac7..cb57bc0ce72 100644 --- a/settings/templates/admin.php +++ b/settings/templates/admin.php @@ -263,16 +263,14 @@ if (!$_['internetconnectionworking']) { value="1" <?php if ($_['allowResharing'] === 'yes') print_unescaped('checked="checked"'); ?> /> <label for="allowResharing"><?php p($l->t('Allow resharing'));?></label><br/> <em><?php p($l->t('Allow users to share items shared with them again')); ?></em> - </td> - </tr> - <tr> - <td <?php if ($_['shareAPIEnabled'] === 'no') print_unescaped('class="hidden"');?>> - <input type="radio" name="shareapi_share_policy" id="sharePolicyGlobal" - value="global" <?php if ($_['sharePolicy'] === 'global') print_unescaped('checked="checked"'); ?> /> - <label for="sharePolicyGlobal"><?php p($l->t('Allow users to share with anyone')); ?></label><br/> - <input type="radio" name="shareapi_share_policy" id="sharePolicyGroupsOnly" - value="groups_only" <?php if ($_['sharePolicy'] === 'groups_only') print_unescaped('checked="checked"'); ?> /> - <label for="sharePolicyGroupsOnly"><?php p($l->t('Allow users to only share with users in their groups'));?></label><br/> + <div id="resharingSettings" <?php ($_['allowResharing'] === 'yes') ? print_unescaped('class="indent"') : print_unescaped('class="hidden indent"');?>> + <input type="radio" name="shareapi_share_policy" id="sharePolicyGlobal" + value="global" <?php if ($_['sharePolicy'] === 'global') print_unescaped('checked="checked"'); ?> /> + <label for="sharePolicyGlobal"><?php p($l->t('Allow users to share with anyone')); ?></label><br/> + <input type="radio" name="shareapi_share_policy" id="sharePolicyGroupsOnly" + value="groups_only" <?php if ($_['sharePolicy'] === 'groups_only') print_unescaped('checked="checked"'); ?> /> + <label for="sharePolicyGroupsOnly"><?php p($l->t('Allow users to only share with users in their groups'));?></label><br/> + </div> </td> </tr> <tr> |