diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/config.php | 7 | ||||
-rw-r--r-- | lib/private/defaults.php | 18 | ||||
-rw-r--r-- | lib/private/files/cache/cache.php | 3 | ||||
-rw-r--r-- | lib/private/files/cache/changepropagator.php | 4 | ||||
-rw-r--r-- | lib/private/files/cache/scanner.php | 194 | ||||
-rw-r--r-- | lib/private/files/filesystem.php | 9 | ||||
-rw-r--r-- | lib/private/httphelper.php | 3 | ||||
-rw-r--r-- | lib/private/image.php | 2 | ||||
-rw-r--r-- | lib/private/installer.php | 2 | ||||
-rw-r--r-- | lib/private/json.php | 46 | ||||
-rw-r--r-- | lib/private/memcache/arraycache.php | 71 | ||||
-rw-r--r-- | lib/private/memcache/factory.php | 2 | ||||
-rw-r--r-- | lib/private/repair.php | 2 | ||||
-rw-r--r-- | lib/private/security/securerandom.php | 3 | ||||
-rw-r--r-- | lib/private/share/share.php | 10 | ||||
-rw-r--r-- | lib/private/urlgenerator.php | 8 | ||||
-rw-r--r-- | lib/private/user.php | 2 | ||||
-rw-r--r-- | lib/private/util.php | 39 |
18 files changed, 300 insertions, 125 deletions
diff --git a/lib/private/config.php b/lib/private/config.php index 31e536221dd..5c8cc89f0f0 100644 --- a/lib/private/config.php +++ b/lib/private/config.php @@ -236,8 +236,11 @@ class Config { flock($filePointer, LOCK_UN); fclose($filePointer); - // Clear the opcode cache - \OC_Util::clearOpcodeCache(); + // Try invalidating the opcache just for the file we wrote... + if (!\OC_Util::deleteFromOpcodeCache($this->configFilePath)) { + // But if that doesn't work, clear the whole cache. + \OC_Util::clearOpcodeCache(); + } } } diff --git a/lib/private/defaults.php b/lib/private/defaults.php index c16ebdbe24c..a3902ee80de 100644 --- a/lib/private/defaults.php +++ b/lib/private/defaults.php @@ -1,9 +1,5 @@ <?php -if (file_exists(OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php')) { - require_once 'themes/' . OC_Util::getTheme() . '/defaults.php'; -} - /** * Default strings and values which differ between the enterprise and the * community edition. Use the get methods to always get the right strings. @@ -45,8 +41,15 @@ class OC_Defaults { $this->defaultLogoClaim = ''; $this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */ - if (class_exists('OC_Theme')) { - $this->theme = new OC_Theme(); + $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; + if (file_exists($themePath)) { + // prevent defaults.php from printing output + ob_start(); + require_once $themePath; + ob_end_clean(); + if (class_exists('OC_Theme')) { + $this->theme = new OC_Theme(); + } } } @@ -212,7 +215,8 @@ class OC_Defaults { if ($this->themeExist('getShortFooter')) { $footer = $this->theme->getShortFooter(); } else { - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank">' .$this->getEntity() . '</a>'. + $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . + ' rel="noreferrer">' .$this->getEntity() . '</a>'. ' – ' . $this->getSlogan(); } diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index 06a884072e0..48b2b5c024b 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -193,6 +193,9 @@ class Cache { $file['size'] = $file['unencrypted_size']; } $file['permissions'] = (int)$file['permissions']; + $file['mtime'] = (int)$file['mtime']; + $file['storage_mtime'] = (int)$file['storage_mtime']; + $file['size'] = 0 + $file['size']; } return $files; } else { diff --git a/lib/private/files/cache/changepropagator.php b/lib/private/files/cache/changepropagator.php index 2967c8f6259..36fc6e80144 100644 --- a/lib/private/files/cache/changepropagator.php +++ b/lib/private/files/cache/changepropagator.php @@ -59,8 +59,8 @@ class ChangePropagator { list($storage, $internalPath) = $this->view->resolvePath($parent); if ($storage) { $cache = $storage->getCache(); - $id = $cache->getId($internalPath); - $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath))); + $entry = $cache->get($internalPath); + $cache->update($entry['fileid'], array('mtime' => max($time, $entry['mtime']), 'etag' => $storage->getETag($internalPath))); } } } diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index 4778a6803ba..d369398af1c 100644 --- a/lib/private/files/cache/scanner.php +++ b/lib/private/files/cache/scanner.php @@ -80,7 +80,8 @@ class Scanner extends BasicEmitter { * @return array an array of metadata of the file */ public function getData($path) { - if (!$this->storage->isReadable($path)) { + $permissions = $this->storage->getPermissions($path); + if (!$permissions & \OCP\PERMISSION_READ) { //cant read, nothing we can do \OCP\Util::writeLog('OC\Files\Cache\Scanner', "!!! Path '$path' is not accessible or present !!!", \OCP\Util::DEBUG); return null; @@ -95,7 +96,7 @@ class Scanner extends BasicEmitter { } $data['etag'] = $this->storage->getETag($path); $data['storage_mtime'] = $data['mtime']; - $data['permissions'] = $this->storage->getPermissions($path); + $data['permissions'] = $permissions; return $data; } @@ -104,9 +105,11 @@ class Scanner extends BasicEmitter { * * @param string $file * @param int $reuseExisting + * @param int $parentId + * @param array | null $cacheData existing data in the cache for the file to be scanned * @return array an array of metadata of the scanned file */ - public function scanFile($file, $reuseExisting = 0) { + public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null) { if (!self::isPartialFile($file) and !Filesystem::isFileBlacklisted($file) ) { @@ -118,7 +121,9 @@ class Scanner extends BasicEmitter { if ($parent === '.' or $parent === '/') { $parent = ''; } - $parentId = $this->cache->getId($parent); + if ($parentId === -1) { + $parentId = $this->cache->getId($parent); + } // scan the parent if it's not in the cache (id -1) and the current file is not the root folder if ($file and $parentId === -1) { @@ -128,14 +133,18 @@ class Scanner extends BasicEmitter { if ($parent) { $data['parent'] = $parentId; } - $cacheData = $this->cache->get($file); - if ($cacheData and $reuseExisting) { + if (is_null($cacheData)) { + $cacheData = $this->cache->get($file); + } + if ($cacheData and $reuseExisting and isset($cacheData['fileid'])) { // prevent empty etag if (empty($cacheData['etag'])) { $etag = $data['etag']; } else { $etag = $cacheData['etag']; } + $fileId = $cacheData['fileid']; + $data['fileid'] = $fileId; // only reuse data if the file hasn't explicitly changed if (isset($data['storage_mtime']) && isset($cacheData['storage_mtime']) && $data['storage_mtime'] === $cacheData['storage_mtime']) { $data['mtime'] = $cacheData['mtime']; @@ -150,9 +159,10 @@ class Scanner extends BasicEmitter { $newData = array_diff_assoc($data, $cacheData); } else { $newData = $data; + $fileId = -1; } if (!empty($newData)) { - $data['fileid'] = $this->addToCache($file, $newData); + $data['fileid'] = $this->addToCache($file, $newData, $fileId); $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId)); \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId)); } @@ -175,13 +185,19 @@ class Scanner extends BasicEmitter { /** * @param string $path * @param array $data + * @param int $fileId * @return int the id of the added file */ - protected function addToCache($path, $data) { + protected function addToCache($path, $data, $fileId = -1) { \OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'data' => $data)); $this->emit('\OC\Files\Cache\Scanner', 'addToCache', array($path, $this->storageId, $data)); if ($this->cacheActive) { - return $this->cache->put($path, $data); + if ($fileId !== -1) { + $this->cache->update($fileId, $data); + return $fileId; + } else { + return $this->cache->put($path, $data); + } } else { return -1; } @@ -190,12 +206,17 @@ class Scanner extends BasicEmitter { /** * @param string $path * @param array $data + * @param int $fileId */ - protected function updateCache($path, $data) { + protected function updateCache($path, $data, $fileId = -1) { \OC_Hook::emit('Scanner', 'addToCache', array('file' => $path, 'data' => $data)); $this->emit('\OC\Files\Cache\Scanner', 'updateCache', array($path, $this->storageId, $data)); if ($this->cacheActive) { - $this->cache->put($path, $data); + if ($fileId !== -1) { + $this->cache->update($fileId, $data); + } else { + $this->cache->put($path, $data); + } } } @@ -212,97 +233,124 @@ class Scanner extends BasicEmitter { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } $data = $this->scanFile($path, $reuse); - if ($data !== null) { - $size = $this->scanChildren($path, $recursive, $reuse); + if ($data and $data['mimetype'] === 'httpd/unix-directory') { + $size = $this->scanChildren($path, $recursive, $reuse, $data); $data['size'] = $size; } return $data; } - protected function getExistingChildren($path) { + /** + * Get the children currently in the cache + * + * @param int $folderId + * @return array[] + */ + protected function getExistingChildren($folderId) { $existingChildren = array(); - if ($this->cache->inCache($path)) { - $children = $this->cache->getFolderContents($path); - foreach ($children as $child) { - $existingChildren[] = $child['name']; - } + $children = $this->cache->getFolderContentsById($folderId); + foreach ($children as $child) { + $existingChildren[$child['name']] = $child; } return $existingChildren; } /** + * Get the children from the storage + * + * @param string $folder + * @return string[] + */ + protected function getNewChildren($folder) { + $children = array(); + if ($dh = $this->storage->opendir($folder)) { + if (is_resource($dh)) { + while (($file = readdir($dh)) !== false) { + if (!Filesystem::isIgnoredDir($file)) { + $children[] = $file; + } + } + } + } + return $children; + } + + /** * scan all the files and folders in a folder * * @param string $path * @param bool $recursive * @param int $reuse + * @param array $folderData existing cache data for the folder to be scanned * @return int the size of the scanned folder or -1 if the size is unknown at this stage */ - public function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1) { + protected function scanChildren($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $folderData = null) { if ($reuse === -1) { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } $this->emit('\OC\Files\Cache\Scanner', 'scanFolder', array($path, $this->storageId)); $size = 0; $childQueue = array(); - $existingChildren = $this->getExistingChildren($path); - $newChildren = array(); - if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) { - $exceptionOccurred = false; - if ($this->useTransactions) { - \OC_DB::beginTransaction(); - } - if (is_resource($dh)) { - while (($file = readdir($dh)) !== false) { - $child = ($path) ? $path . '/' . $file : $file; - if (!Filesystem::isIgnoredDir($file)) { - $newChildren[] = $file; - try { - $data = $this->scanFile($child, $reuse); - if ($data) { - if ($data['mimetype'] === 'httpd/unix-directory' and $recursive === self::SCAN_RECURSIVE) { - $childQueue[] = $child; - } else if ($data['size'] === -1) { - $size = -1; - } else if ($size !== -1) { - $size += $data['size']; - } - } - } catch (\Doctrine\DBAL\DBALException $ex) { - // might happen if inserting duplicate while a scanning - // process is running in parallel - // log and ignore - \OC_Log::write('core', 'Exception while scanning file "' . $child . '": ' . $ex->getMessage(), \OC_Log::DEBUG); - $exceptionOccurred = true; - } + if (is_array($folderData) and isset($folderData['fileid'])) { + $folderId = $folderData['fileid']; + } else { + $folderId = $this->cache->getId($path); + } + $existingChildren = $this->getExistingChildren($folderId); + $newChildren = $this->getNewChildren($path); + + if ($this->useTransactions) { + \OC_DB::beginTransaction(); + } + $exceptionOccurred = false; + foreach ($newChildren as $file) { + $child = ($path) ? $path . '/' . $file : $file; + try { + $existingData = isset($existingChildren[$file]) ? $existingChildren[$file] : null; + $data = $this->scanFile($child, $reuse, $folderId, $existingData); + if ($data) { + if ($data['mimetype'] === 'httpd/unix-directory' and $recursive === self::SCAN_RECURSIVE) { + $childQueue[$child] = $data; + } else if ($data['size'] === -1) { + $size = -1; + } else if ($size !== -1) { + $size += $data['size']; } } + } catch (\Doctrine\DBAL\DBALException $ex) { + // might happen if inserting duplicate while a scanning + // process is running in parallel + // log and ignore + \OC_Log::write('core', 'Exception while scanning file "' . $child . '": ' . $ex->getMessage(), \OC_Log::DEBUG); + $exceptionOccurred = true; } - $removedChildren = \array_diff($existingChildren, $newChildren); - foreach ($removedChildren as $childName) { - $child = ($path) ? $path . '/' . $childName : $childName; - $this->removeFromCache($child); - } - if ($this->useTransactions) { - \OC_DB::commit(); - } - if ($exceptionOccurred) { - // It might happen that the parallel scan process has already - // inserted mimetypes but those weren't available yet inside the transaction - // To make sure to have the updated mime types in such cases, - // we reload them here - $this->cache->loadMimetypes(); - } + } + $removedChildren = \array_diff(array_keys($existingChildren), $newChildren); + foreach ($removedChildren as $childName) { + $child = ($path) ? $path . '/' . $childName : $childName; + $this->removeFromCache($child); + } + if ($this->useTransactions) { + \OC_DB::commit(); + } + if ($exceptionOccurred) { + // It might happen that the parallel scan process has already + // inserted mimetypes but those weren't available yet inside the transaction + // To make sure to have the updated mime types in such cases, + // we reload them here + $this->cache->loadMimetypes(); + } - foreach ($childQueue as $child) { - $childSize = $this->scanChildren($child, self::SCAN_RECURSIVE, $reuse); - if ($childSize === -1) { - $size = -1; - } else if ($size !== -1) { - $size += $childSize; - } + foreach ($childQueue as $child => $childData) { + $childSize = $this->scanChildren($child, self::SCAN_RECURSIVE, $reuse, $childData); + if ($childSize === -1) { + $size = -1; + } else if ($size !== -1) { + $size += $childSize; } - $this->updateCache($path, array('size' => $size)); + } + if (!is_array($folderData) or !isset($folderData['size']) or $folderData['size'] !== $size) { + $this->updateCache($path, array('size' => $size), $folderId); } $this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', array($path, $this->storageId)); return $size; diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index e933782ce2f..04f82d88cd1 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -723,9 +723,18 @@ class Filesystem { * Fix common problems with a file path * @param string $path * @param bool $stripTrailingSlash + * @param bool $isAbsolutePath * @return string */ public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false) { + /** + * FIXME: This is a workaround for existing classes and files which call + * this function with another type than a valid string. This + * conversion should get removed as soon as all existing + * function calls have been fixed. + */ + $path = (string)$path; + $cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath]); if(isset(self::$normalizedPathCache[$cacheKey])) { diff --git a/lib/private/httphelper.php b/lib/private/httphelper.php index 1f3482b3514..08c35e4ae08 100644 --- a/lib/private/httphelper.php +++ b/lib/private/httphelper.php @@ -214,7 +214,8 @@ class HTTPHelper { curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, count($fields)); - curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsString); + curl_setopt($ch, CURLOPT_POSTFIELDS, (string)$fieldsString); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); if (is_readable($certBundle)) { curl_setopt($ch, CURLOPT_CAINFO, $certBundle); } diff --git a/lib/private/image.php b/lib/private/image.php index f5f9a04facc..317b6fde160 100644 --- a/lib/private/image.php +++ b/lib/private/image.php @@ -391,7 +391,7 @@ class OC_Image { $rotate = 90; break; } - if($flip) { + if($flip && function_exists('imageflip')) { imageflip($this->resource, IMG_FLIP_HORIZONTAL); } if ($rotate) { diff --git a/lib/private/installer.php b/lib/private/installer.php index e50b5cea452..aeac3497fd7 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -241,7 +241,7 @@ class OC_Installer{ if(!isset($data['href'])) { throw new \Exception($l->t("No href specified when installing app from http")); } - copy($data['href'], $path); + file_put_contents($path, \OC_Util::getUrlContent($data['href'])); }else{ if(!isset($data['path'])) { throw new \Exception($l->t("No path specified when installing app from local file")); diff --git a/lib/private/json.php b/lib/private/json.php index f2719dd2bc7..9117abf7fb9 100644 --- a/lib/private/json.php +++ b/lib/private/json.php @@ -6,10 +6,15 @@ * See the COPYING-README file. */ +/** + * Class OC_JSON + * @deprecated Use a AppFramework JSONResponse instead + */ class OC_JSON{ static protected $send_content_type_header = false; /** * set Content-Type header to jsonrequest + * @deprecated Use a AppFramework JSONResponse instead */ public static function setContentTypeHeader($type='application/json') { if (!self::$send_content_type_header) { @@ -20,9 +25,10 @@ class OC_JSON{ } /** - * Check if the app is enabled, send json error msg if not - * @param string $app - */ + * Check if the app is enabled, send json error msg if not + * @param string $app + * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled. + */ public static function checkAppEnabled($app) { if( !OC_App::isEnabled($app)) { $l = \OC::$server->getL10N('lib'); @@ -32,8 +38,9 @@ class OC_JSON{ } /** - * Check if the user is logged in, send json error msg if not - */ + * Check if the user is logged in, send json error msg if not + * @deprecated Use annotation based ACLs from the AppFramework instead + */ public static function checkLoggedIn() { if( !OC_User::isLoggedIn()) { $l = \OC::$server->getL10N('lib'); @@ -44,6 +51,7 @@ class OC_JSON{ /** * Check an ajax get/post call if the request token is valid, send json error msg if not. + * @deprecated Use annotation based CSRF checks from the AppFramework instead */ public static function callCheck() { if( !OC_Util::isCallRegistered()) { @@ -54,8 +62,9 @@ class OC_JSON{ } /** - * Check if the user is a admin, send json error msg if not. - */ + * Check if the user is a admin, send json error msg if not. + * @deprecated Use annotation based ACLs from the AppFramework instead + */ public static function checkAdminUser() { if( !OC_User::isAdminUser(OC_User::getUser())) { $l = \OC::$server->getL10N('lib'); @@ -67,6 +76,7 @@ class OC_JSON{ /** * Check is a given user exists - send json error msg if not * @param string $user + * @deprecated Use a AppFramework JSONResponse instead */ public static function checkUserExists($user) { if (!OCP\User::userExists($user)) { @@ -77,10 +87,10 @@ class OC_JSON{ } - /** - * Check if the user is a subadmin, send json error msg if not - */ + * Check if the user is a subadmin, send json error msg if not + * @deprecated Use annotation based ACLs from the AppFramework instead + */ public static function checkSubAdminUser() { if(!OC_SubAdmin::isSubAdmin(OC_User::getUser())) { $l = \OC::$server->getL10N('lib'); @@ -90,16 +100,18 @@ class OC_JSON{ } /** - * Send json error msg - */ + * Send json error msg + * @deprecated Use a AppFramework JSONResponse instead + */ public static function error($data = array()) { $data['status'] = 'error'; self::encodedPrint($data); } /** - * Send json success msg - */ + * Send json success msg + * @deprecated Use a AppFramework JSONResponse instead + */ public static function success($data = array()) { $data['status'] = 'success'; self::encodedPrint($data); @@ -115,8 +127,9 @@ class OC_JSON{ } /** - * Encode and print $data in json format - */ + * Encode and print $data in json format + * @deprecated Use a AppFramework JSONResponse instead + */ public static function encodedPrint($data, $setContentType=true) { if($setContentType) { self::setContentTypeHeader(); @@ -126,6 +139,7 @@ class OC_JSON{ /** * Encode JSON + * @deprecated Use a AppFramework JSONResponse instead */ public static function encode($data) { if (is_array($data)) { diff --git a/lib/private/memcache/arraycache.php b/lib/private/memcache/arraycache.php new file mode 100644 index 00000000000..9456c0f80c6 --- /dev/null +++ b/lib/private/memcache/arraycache.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright (c) 2015 Joas Schilling <nickvergessen@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Memcache; + +class ArrayCache extends Cache { + /** @var array Array with the cached data */ + protected $cachedData = array(); + + /** + * {@inheritDoc} + */ + public function get($key) { + if ($this->hasKey($key)) { + return $this->cachedData[$key]; + } + return null; + } + + /** + * {@inheritDoc} + */ + public function set($key, $value, $ttl = 0) { + $this->cachedData[$key] = $value; + return true; + } + + /** + * {@inheritDoc} + */ + public function hasKey($key) { + return isset($this->cachedData[$key]); + } + + /** + * {@inheritDoc} + */ + public function remove($key) { + unset($this->cachedData[$key]); + return true; + } + + /** + * {@inheritDoc} + */ + public function clear($prefix = '') { + if ($prefix === '') { + $this->cachedData = []; + return true; + } + + foreach ($this->cachedData as $key => $value) { + if (strpos($key, $prefix) === 0) { + $this->remove($key); + } + } + return true; + } + + /** + * {@inheritDoc} + */ + static public function isAvailable() { + return true; + } +} diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php index 1e663eecfe1..e8a91c52269 100644 --- a/lib/private/memcache/factory.php +++ b/lib/private/memcache/factory.php @@ -42,7 +42,7 @@ class Factory implements ICacheFactory { } elseif (Memcached::isAvailable()) { return new Memcached($prefix); } else { - return new Null($prefix); + return new ArrayCache($prefix); } } diff --git a/lib/private/repair.php b/lib/private/repair.php index c74283896fd..d9fd99707e8 100644 --- a/lib/private/repair.php +++ b/lib/private/repair.php @@ -13,7 +13,6 @@ use OC\Hooks\Emitter; use OC\Repair\AssetCache; use OC\Repair\CleanTags; use OC\Repair\Collation; -use OC\Repair\EnableFilesApp; use OC\Repair\FillETags; use OC\Repair\InnoDB; use OC\Repair\RepairConfig; @@ -85,7 +84,6 @@ class Repair extends BasicEmitter { new AssetCache(), new FillETags(\OC_DB::getConnection()), new CleanTags(\OC_DB::getConnection()), - new EnableFilesApp(\OC::$server->getConfig()), ); } diff --git a/lib/private/security/securerandom.php b/lib/private/security/securerandom.php index 2402e863fb0..b1169bff289 100644 --- a/lib/private/security/securerandom.php +++ b/lib/private/security/securerandom.php @@ -64,8 +64,7 @@ class SecureRandom implements ISecureRandom { * Generate a random string of specified length. * @param string $length The length of the generated string * @param string $characters An optional list of characters to use if no characterlist is - * specified 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ./ - * is used. + * specified all valid base64 characters are used. * @return string * @throws \Exception If the generator is not initialized. */ diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 53479ad7144..4753f6ecbfa 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -1857,7 +1857,7 @@ class Share extends \OC\Share\Constants { $sourceId = ($itemType === 'file' || $itemType === 'folder') ? $fileSource : $itemSource; $sourceExists = self::getItemSharedWithBySource($itemType, $sourceId, self::FORMAT_NONE, null, true, $user); - $shareType = ($isGroupShare) ? self::$shareTypeGroupUserUnique : $shareType; + $userShareType = ($isGroupShare) ? self::$shareTypeGroupUserUnique : $shareType; if ($sourceExists) { $fileTarget = $sourceExists['file_target']; @@ -1870,12 +1870,12 @@ class Share extends \OC\Share\Constants { } elseif(!$sourceExists && !$isGroupShare) { - $itemTarget = Helper::generateTarget($itemType, $itemSource, $shareType, $user, + $itemTarget = Helper::generateTarget($itemType, $itemSource, $userShareType, $user, $uidOwner, $suggestedItemTarget, $parent); if (isset($fileSource)) { if ($parentFolder) { if ($parentFolder === true) { - $fileTarget = Helper::generateTarget('file', $filePath, $shareType, $user, + $fileTarget = Helper::generateTarget('file', $filePath, $userShareType, $user, $uidOwner, $suggestedFileTarget, $parent); if ($fileTarget != $groupFileTarget) { $parentFolders[$user]['folder'] = $fileTarget; @@ -1885,7 +1885,7 @@ class Share extends \OC\Share\Constants { $parent = $parentFolder[$user]['id']; } } else { - $fileTarget = Helper::generateTarget('file', $filePath, $shareType, + $fileTarget = Helper::generateTarget('file', $filePath, $userShareType, $user, $uidOwner, $suggestedFileTarget, $parent); } } else { @@ -1916,7 +1916,7 @@ class Share extends \OC\Share\Constants { 'itemType' => $itemType, 'itemSource' => $itemSource, 'itemTarget' => $itemTarget, - 'shareType' => $shareType, + 'shareType' => $userShareType, 'shareWith' => $user, 'uidOwner' => $uidOwner, 'permissions' => $permissions, diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php index d263d25aeef..0bf8ce22998 100644 --- a/lib/private/urlgenerator.php +++ b/lib/private/urlgenerator.php @@ -32,8 +32,7 @@ class URLGenerator implements IURLGenerator { /** * Creates an url using a defined route * @param string $route - * @param array $parameters - * @internal param array $args with param=>value, will be appended to the returned url + * @param array $parameters args with param=>value, will be appended to the returned url * @return string the url * * Returns a url to the given route. @@ -45,9 +44,8 @@ class URLGenerator implements IURLGenerator { /** * Creates an absolute url using a defined route - * @param string $route - * @param array $parameters - * @internal param array $args with param=>value, will be appended to the returned url + * @param string $routeName + * @param array $arguments args with param=>value, will be appended to the returned url * @return string the url * * Returns an absolute url to the given route. diff --git a/lib/private/user.php b/lib/private/user.php index d1fedffcaaf..10457c224f2 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -366,7 +366,7 @@ class OC_User { return $backend->getLogoutAttribute(); } - return 'href="' . link_to('', 'index.php') . '?logout=true&requesttoken=' . OC_Util::callRegister() . '"'; + return 'href="' . link_to('', 'index.php') . '?logout=true&requesttoken=' . urlencode(OC_Util::callRegister()) . '"'; } /** diff --git a/lib/private/util.php b/lib/private/util.php index 9a01ca3ac95..2be7e8eb293 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -504,11 +504,6 @@ class OC_Util { $webServerRestart = true; } - //common hint for all file permissions error messages - $permissionsHint = $l->t('Permissions can usually be fixed by ' - . '%sgiving the webserver write access to the root directory%s.', - array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')); - // Check if config folder is writable. if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) { $errors[] = array( @@ -549,6 +544,10 @@ class OC_Util { ); } } else if (!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { + //common hint for all file permissions error messages + $permissionsHint = $l->t('Permissions can usually be fixed by ' + . '%sgiving the webserver write access to the root directory%s.', + array('<a href="' . \OC_Helper::linkToDocs('admin-dir_permissions') . '" target="_blank">', '</a>')); $errors[] = array( 'error' => 'Data directory (' . $CONFIG_DATADIRECTORY . ') not writable by ownCloud', 'hint' => $permissionsHint @@ -1272,6 +1271,32 @@ class OC_Util { } /** + * Clear a single file from the opcode cache + * This is useful for writing to the config file + * in case the opcode cache does not re-validate files + * Returns true if successful, false if unsuccessful: + * caller should fall back on clearing the entire cache + * with clearOpcodeCache() if unsuccessful + * + * @param string $path the path of the file to clear from the cache + * @return bool true if underlying function returns true, otherwise false + */ + public static function deleteFromOpcodeCache($path) { + $ret = false; + if ($path) { + // APC >= 3.1.1 + if (function_exists('apc_delete_file')) { + $ret = @apc_delete_file($path); + } + // Zend OpCache >= 7.0.0, PHP >= 5.5.0 + if (function_exists('opcache_invalidate')) { + $ret = opcache_invalidate($path); + } + } + return $ret; + } + + /** * Clear the opcode cache if one exists * This is necessary for writing to the config file * in case the opcode cache does not re-validate files @@ -1399,10 +1424,12 @@ class OC_Util { } /** + * Check if PhpCharset config is UTF-8 + * * @return string */ public static function isPhpCharSetUtf8() { - return ini_get('default_charset') === 'UTF-8'; + return strtoupper(ini_get('default_charset')) === 'UTF-8'; } } |