summaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/OC_API.php10
-rw-r--r--lib/private/legacy/OC_App.php32
-rw-r--r--lib/private/legacy/OC_DB.php2
-rw-r--r--lib/private/legacy/OC_Defaults.php6
-rw-r--r--lib/private/legacy/OC_EventSource.php2
-rw-r--r--lib/private/legacy/OC_FileChunking.php4
-rw-r--r--lib/private/legacy/OC_Files.php51
-rw-r--r--lib/private/legacy/OC_Helper.php7
-rw-r--r--lib/private/legacy/OC_Hook.php20
-rw-r--r--lib/private/legacy/OC_Image.php2
-rw-r--r--lib/private/legacy/OC_JSON.php12
-rw-r--r--lib/private/legacy/OC_Response.php3
-rw-r--r--lib/private/legacy/OC_Template.php19
-rw-r--r--lib/private/legacy/OC_User.php2
-rw-r--r--lib/private/legacy/OC_Util.php30
-rw-r--r--lib/private/legacy/template/functions.php32
16 files changed, 104 insertions, 130 deletions
diff --git a/lib/private/legacy/OC_API.php b/lib/private/legacy/OC_API.php
index b9960c70777..37a496a38fe 100644
--- a/lib/private/legacy/OC_API.php
+++ b/lib/private/legacy/OC_API.php
@@ -48,9 +48,9 @@ class OC_API {
$request = \OC::$server->getRequest();
// Send 401 headers if unauthorised
- if($result->getStatusCode() === API::RESPOND_UNAUTHORISED) {
+ if ($result->getStatusCode() === API::RESPOND_UNAUTHORISED) {
// If request comes from JS return dummy auth request
- if($request->getHeader('X-Requested-With') === 'XMLHttpRequest') {
+ if ($request->getHeader('X-Requested-With') === 'XMLHttpRequest') {
header('WWW-Authenticate: DummyBasic realm="Authorisation Required"');
} else {
header('WWW-Authenticate: Basic realm="Authorisation Required"');
@@ -58,7 +58,7 @@ class OC_API {
http_response_code(401);
}
- foreach($result->getHeaders() as $name => $value) {
+ foreach ($result->getHeaders() as $name => $value) {
header($name . ': ' . $value);
}
@@ -81,14 +81,14 @@ class OC_API {
* @param XMLWriter $writer
*/
private static function toXML($array, $writer) {
- foreach($array as $k => $v) {
+ foreach ($array as $k => $v) {
if ($k[0] === '@') {
$writer->writeAttribute(substr($k, 1), $v);
continue;
} elseif (is_numeric($k)) {
$k = 'element';
}
- if(is_array($v)) {
+ if (is_array($v)) {
$writer->startElement($k);
self::toXML($v, $writer);
$writer->endElement();
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index 3cc194cc03d..5c06f66a20a 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -114,9 +114,9 @@ class OC_App {
$apps = self::getEnabledApps();
// Add each apps' folder as allowed class path
- foreach($apps as $app) {
+ foreach ($apps as $app) {
$path = self::getAppPath($app);
- if($path !== false) {
+ if ($path !== false) {
self::registerAutoloading($app, $path);
}
}
@@ -142,7 +142,7 @@ class OC_App {
public static function loadApp(string $app) {
self::$loadedApps[] = $app;
$appPath = self::getAppPath($app);
- if($appPath === false) {
+ if ($appPath === false) {
return;
}
@@ -154,7 +154,7 @@ class OC_App {
try {
self::requireAppFile($app);
} catch (Throwable $ex) {
- if($ex instanceof ServerNotAvailableException) {
+ if ($ex instanceof ServerNotAvailableException) {
throw $ex;
}
\OC::$server->getLogger()->logException($ex);
@@ -210,7 +210,7 @@ class OC_App {
$plugins = isset($info['collaboration']['plugins']['plugin']['@value']) ?
[$info['collaboration']['plugins']['plugin']] : $info['collaboration']['plugins']['plugin'];
foreach ($plugins as $plugin) {
- if($plugin['@attributes']['type'] === 'collaborator-search') {
+ if ($plugin['@attributes']['type'] === 'collaborator-search') {
$pluginInfo = [
'shareType' => $plugin['@attributes']['share-type'],
'class' => $plugin['@value'],
@@ -308,7 +308,7 @@ class OC_App {
public static function setAppTypes(string $app) {
$appManager = \OC::$server->getAppManager();
$appData = $appManager->getAppInfo($app);
- if(!is_array($appData)) {
+ if (!is_array($appData)) {
return;
}
@@ -395,7 +395,7 @@ class OC_App {
$installer = \OC::$server->query(Installer::class);
$isDownloaded = $installer->isDownloaded($appId);
- if(!$isDownloaded) {
+ if (!$isDownloaded) {
$installer->downloadApp($appId);
}
@@ -446,7 +446,7 @@ class OC_App {
*/
public static function findAppInDirectories(string $appId) {
$sanitizedAppId = self::cleanAppId($appId);
- if($sanitizedAppId !== $appId) {
+ if ($sanitizedAppId !== $appId) {
return false;
}
static $app_dir = [];
@@ -671,7 +671,6 @@ class OC_App {
* @todo: change the name of this method to getInstalledApps, which is more accurate
*/
public static function getAllApps(): array {
-
$apps = [];
foreach (OC::$APPSROOTS as $apps_dir) {
@@ -683,9 +682,7 @@ class OC_App {
if (is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
-
if ($file[0] != '.' and is_dir($apps_dir['path'] . '/' . $file) and is_file($apps_dir['path'] . '/' . $file . '/appinfo/info.xml')) {
-
$apps[] = $file;
}
}
@@ -717,7 +714,6 @@ class OC_App {
foreach ($installedApps as $app) {
if (array_search($app, $blacklist) === false) {
-
$info = OC_App::getAppInfo($app, false, $langCode);
if (!is_array($info)) {
\OCP\Util::writeLog('core', 'Could not read app info file for app "' . $app . '"', ILogger::ERROR);
@@ -756,7 +752,7 @@ class OC_App {
}
$appPath = self::getAppPath($app);
- if($appPath !== false) {
+ if ($appPath !== false) {
$appIcon = $appPath . '/img/' . $app . '.svg';
if (file_exists($appIcon)) {
$info['preview'] = $urlGenerator->imagePath($app, $app . '.svg');
@@ -864,7 +860,6 @@ class OC_App {
if (!empty($requireMin)
&& version_compare(self::adjustVersionParts($ocVersion, $requireMin), $requireMin, '<')
) {
-
return false;
}
@@ -883,7 +878,7 @@ class OC_App {
public static function getAppVersions() {
static $versions;
- if(!$versions) {
+ if (!$versions) {
$appConfig = \OC::$server->getAppConfig();
$versions = $appConfig->getValues(false, 'installed_version');
}
@@ -898,7 +893,7 @@ class OC_App {
*/
public static function updateApp(string $appId): bool {
$appPath = self::getAppPath($appId);
- if($appPath === false) {
+ if ($appPath === false) {
return false;
}
@@ -931,7 +926,7 @@ class OC_App {
//set remote/public handlers
if (array_key_exists('ocsid', $appData)) {
\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
- } elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
+ } elseif (\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
\OC::$server->getConfig()->deleteAppValue($appId, 'ocsid');
}
foreach ($appData['remote'] as $name => $path) {
@@ -1081,7 +1076,6 @@ class OC_App {
* @return array improved app data
*/
public static function parseAppInfo(array $data, $lang = null): array {
-
if ($lang && isset($data['name']) && is_array($data['name'])) {
$data['name'] = self::findBestL10NOption($data['name'], $lang);
}
@@ -1092,7 +1086,7 @@ class OC_App {
$data['description'] = trim(self::findBestL10NOption($data['description'], $lang));
} elseif (isset($data['description']) && is_string($data['description'])) {
$data['description'] = trim($data['description']);
- } else {
+ } else {
$data['description'] = '';
}
diff --git a/lib/private/legacy/OC_DB.php b/lib/private/legacy/OC_DB.php
index cf45faae314..63f1447ad91 100644
--- a/lib/private/legacy/OC_DB.php
+++ b/lib/private/legacy/OC_DB.php
@@ -212,7 +212,7 @@ class OC_DB {
* @throws \OC\DatabaseException
*/
public static function raiseExceptionOnError($result, $message = null) {
- if($result === false) {
+ if ($result === false) {
if ($message === null) {
$message = self::getErrorMessage();
} else {
diff --git a/lib/private/legacy/OC_Defaults.php b/lib/private/legacy/OC_Defaults.php
index d5a4b5eecee..f90cae61bd7 100644
--- a/lib/private/legacy/OC_Defaults.php
+++ b/lib/private/legacy/OC_Defaults.php
@@ -36,7 +36,6 @@
*
*/
class OC_Defaults {
-
private $theme;
private $defaultEntity;
@@ -282,7 +281,6 @@ class OC_Defaults {
* @return string
*/
public function getColorPrimary() {
-
if ($this->themeExist('getColorPrimary')) {
return $this->theme->getColorPrimary();
}
@@ -296,7 +294,7 @@ class OC_Defaults {
* @return array scss variables to overwrite
*/
public function getScssVariables() {
- if($this->themeExist('getScssVariables')) {
+ if ($this->themeExist('getScssVariables')) {
return $this->theme->getScssVariables();
}
return [];
@@ -317,7 +315,7 @@ class OC_Defaults {
return $this->theme->getLogo($useSvg);
}
- if($useSvg) {
+ if ($useSvg) {
$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.svg');
} else {
$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.png');
diff --git a/lib/private/legacy/OC_EventSource.php b/lib/private/legacy/OC_EventSource.php
index 7191028295a..b8c4389f985 100644
--- a/lib/private/legacy/OC_EventSource.php
+++ b/lib/private/legacy/OC_EventSource.php
@@ -77,7 +77,7 @@ class OC_EventSource implements \OCP\IEventSource {
} else {
header("Content-Type: text/event-stream");
}
- if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
+ if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
header('Location: '.\OC::$WEBROOT);
exit();
}
diff --git a/lib/private/legacy/OC_FileChunking.php b/lib/private/legacy/OC_FileChunking.php
index 048bd085bb5..37cf42a31cb 100644
--- a/lib/private/legacy/OC_FileChunking.php
+++ b/lib/private/legacy/OC_FileChunking.php
@@ -87,7 +87,7 @@ class OC_FileChunking {
$cache = $this->getCache();
$chunkcount = (int)$this->info['chunkcount'];
- for($i=($chunkcount-1); $i >= 0; $i--) {
+ for ($i=($chunkcount-1); $i >= 0; $i--) {
if (!$cache->hasKey($prefix.$i)) {
return false;
}
@@ -143,7 +143,7 @@ class OC_FileChunking {
public function cleanup() {
$cache = $this->getCache();
$prefix = $this->getPrefix();
- for($i=0; $i < $this->info['chunkcount']; $i++) {
+ for ($i=0; $i < $this->info['chunkcount']; $i++) {
$cache->remove($prefix.$i);
}
}
diff --git a/lib/private/legacy/OC_Files.php b/lib/private/legacy/OC_Files.php
index 710e0882010..e046a577026 100644
--- a/lib/private/legacy/OC_Files.php
+++ b/lib/private/legacy/OC_Files.php
@@ -87,15 +87,13 @@ class OC_Files {
http_response_code(206);
header('Accept-Ranges: bytes', true);
if (count($rangeArray) > 1) {
- $type = 'multipart/byteranges; boundary='.self::getBoundary();
+ $type = 'multipart/byteranges; boundary='.self::getBoundary();
// no Content-Length header here
+ } else {
+ header(sprintf('Content-Range: bytes %d-%d/%d', $rangeArray[0]['from'], $rangeArray[0]['to'], $fileSize), true);
+ OC_Response::setContentLengthHeader($rangeArray[0]['to'] - $rangeArray[0]['from'] + 1);
}
- else {
- header(sprintf('Content-Range: bytes %d-%d/%d', $rangeArray[0]['from'], $rangeArray[0]['to'], $fileSize), true);
- OC_Response::setContentLengthHeader($rangeArray[0]['to'] - $rangeArray[0]['from'] + 1);
- }
- }
- else {
+ } else {
OC_Response::setContentLengthHeader($fileSize);
}
}
@@ -110,12 +108,10 @@ class OC_Files {
* @param array $params ; 'head' boolean to only send header of the request ; 'range' http range header
*/
public static function get($dir, $files, $params = null) {
-
$view = \OC\Files\Filesystem::getView();
$getType = self::FILE;
$filename = $dir;
try {
-
if (is_array($files) && count($files) === 1) {
$files = $files[0];
}
@@ -180,7 +176,7 @@ class OC_Files {
if (\OC\Files\Filesystem::is_file($file)) {
$userFolder = \OC::$server->getRootFolder()->get(\OC\Files\Filesystem::getRoot());
$file = $userFolder->get($file);
- if($file instanceof \OC\Files\Node\File) {
+ if ($file instanceof \OC\Files\Node\File) {
try {
$fh = $file->fopen('r');
} catch (\OCP\Files\NotPermittedException $e) {
@@ -263,13 +259,11 @@ class OC_Files {
if ($minOffset >= $fileSize) {
break;
}
- }
- elseif (is_numeric($ranges[0]) && $ranges[0] < $fileSize) {
+ } elseif (is_numeric($ranges[0]) && $ranges[0] < $fileSize) {
// case: x-
$rangeArray[$ind++] = [ 'from' => $ranges[0], 'to' => $fileSize-1, 'size' => $fileSize ];
break;
- }
- elseif (is_numeric($ranges[1])) {
+ } elseif (is_numeric($ranges[1])) {
// case: -x
if ($ranges[1] > $fileSize) {
$ranges[1] = $fileSize;
@@ -294,7 +288,7 @@ class OC_Files {
try {
$userFolder = \OC::$server->getRootFolder()->get(\OC\Files\Filesystem::getRoot());
$file = $userFolder->get($filename);
- if(!$file instanceof \OC\Files\Node\File || !$file->isReadable()) {
+ if (!$file instanceof \OC\Files\Node\File || !$file->isReadable()) {
http_response_code(403);
die('403 Forbidden');
}
@@ -330,22 +324,21 @@ class OC_Files {
if (!empty($rangeArray)) {
try {
if (count($rangeArray) == 1) {
- $view->readfilePart($filename, $rangeArray[0]['from'], $rangeArray[0]['to']);
- }
- else {
- // check if file is seekable (if not throw UnseekableException)
- // we have to check it before body contents
- $view->readfilePart($filename, $rangeArray[0]['size'], $rangeArray[0]['size']);
+ $view->readfilePart($filename, $rangeArray[0]['from'], $rangeArray[0]['to']);
+ } else {
+ // check if file is seekable (if not throw UnseekableException)
+ // we have to check it before body contents
+ $view->readfilePart($filename, $rangeArray[0]['size'], $rangeArray[0]['size']);
- $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
+ $type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
- foreach ($rangeArray as $range) {
- echo "\r\n--".self::getBoundary()."\r\n".
+ foreach ($rangeArray as $range) {
+ echo "\r\n--".self::getBoundary()."\r\n".
"Content-type: ".$type."\r\n".
"Content-range: bytes ".$range['from']."-".$range['to']."/".$range['size']."\r\n\r\n";
- $view->readfilePart($filename, $range['from'], $range['to']);
- }
- echo "\r\n--".self::getBoundary()."--\r\n";
+ $view->readfilePart($filename, $range['from'], $range['to']);
+ }
+ echo "\r\n--".self::getBoundary()."--\r\n";
}
} catch (\OCP\Files\UnseekableException $ex) {
// file is unseekable
@@ -355,8 +348,7 @@ class OC_Files {
self::sendHeaders($filename, $name, []);
$view->readfile($filename);
}
- }
- else {
+ } else {
$view->readfile($filename);
}
}
@@ -430,5 +422,4 @@ class OC_Files {
$view->unlockFile($file, ILockingProvider::LOCK_SHARED);
}
}
-
}
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index 1c4ce50f4ef..3439d1f8936 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -231,8 +231,9 @@ class OC_Helper {
}
foreach ($dirs as $dir) {
foreach ($exts as $ext) {
- if ($check_fn("$dir/$name" . $ext))
+ if ($check_fn("$dir/$name" . $ext)) {
return true;
+ }
}
}
return false;
@@ -385,7 +386,7 @@ class OC_Helper {
* @return int number of bytes representing
*/
public static function maxUploadFilesize($dir, $freeSpace = null) {
- if (is_null($freeSpace) || $freeSpace < 0){
+ if (is_null($freeSpace) || $freeSpace < 0) {
$freeSpace = self::freeSpace($dir);
}
return min($freeSpace, self::uploadLimit());
@@ -540,7 +541,7 @@ class OC_Helper {
$ownerId = $storage->getOwner($path);
$ownerDisplayName = '';
$owner = \OC::$server->getUserManager()->get($ownerId);
- if($owner) {
+ if ($owner) {
$ownerDisplayName = $owner->getDisplayName();
}
diff --git a/lib/private/legacy/OC_Hook.php b/lib/private/legacy/OC_Hook.php
index b98424711dd..fe08266fe5b 100644
--- a/lib/private/legacy/OC_Hook.php
+++ b/lib/private/legacy/OC_Hook.php
@@ -54,12 +54,12 @@ class OC_Hook {
static public function connect($signalClass, $signalName, $slotClass, $slotName) {
// If we're trying to connect to an emitting class that isn't
// yet registered, register it
- if(!array_key_exists($signalClass, self::$registered)) {
+ if (!array_key_exists($signalClass, self::$registered)) {
self::$registered[$signalClass] = [];
}
// If we're trying to connect to an emitting method that isn't
// yet registered, register it with the emitting class
- if(!array_key_exists($signalName, self::$registered[$signalClass])) {
+ if (!array_key_exists($signalName, self::$registered[$signalClass])) {
self::$registered[$signalClass][$signalName] = [];
}
@@ -95,27 +95,27 @@ class OC_Hook {
// Return false if no hook handlers are listening to this
// emitting class
- if(!array_key_exists($signalClass, self::$registered)) {
+ if (!array_key_exists($signalClass, self::$registered)) {
return false;
}
// Return false if no hook handlers are listening to this
// emitting method
- if(!array_key_exists($signalName, self::$registered[$signalClass])) {
+ if (!array_key_exists($signalName, self::$registered[$signalClass])) {
return false;
}
// Call all slots
- foreach(self::$registered[$signalClass][$signalName] as $i) {
+ foreach (self::$registered[$signalClass][$signalName] as $i) {
try {
call_user_func([ $i["class"], $i["name"] ], $params);
- } catch (Exception $e){
+ } catch (Exception $e) {
self::$thrownExceptions[] = $e;
\OC::$server->getLogger()->logException($e);
- if($e instanceof \OC\HintException) {
+ if ($e instanceof \OC\HintException) {
throw $e;
}
- if($e instanceof \OC\ServerNotAvailableException) {
+ if ($e instanceof \OC\ServerNotAvailableException) {
throw $e;
}
}
@@ -133,10 +133,10 @@ class OC_Hook {
if ($signalClass) {
if ($signalName) {
self::$registered[$signalClass][$signalName]=[];
- }else{
+ } else {
self::$registered[$signalClass]=[];
}
- }else{
+ } else {
self::$registered=[];
}
}
diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php
index 829a9b81652..a3ac82c216d 100644
--- a/lib/private/legacy/OC_Image.php
+++ b/lib/private/legacy/OC_Image.php
@@ -489,7 +489,7 @@ class OC_Image implements \OCP\IImage {
$rotate = 90;
break;
}
- if($flip && function_exists('imageflip')) {
+ if ($flip && function_exists('imageflip')) {
imageflip($this->resource, IMG_FLIP_HORIZONTAL);
}
if ($rotate) {
diff --git a/lib/private/legacy/OC_JSON.php b/lib/private/legacy/OC_JSON.php
index 5b4b97e6fd0..d3a33e3a0f3 100644
--- a/lib/private/legacy/OC_JSON.php
+++ b/lib/private/legacy/OC_JSON.php
@@ -33,7 +33,7 @@
* Class OC_JSON
* @deprecated Use a AppFramework JSONResponse instead
*/
-class OC_JSON{
+class OC_JSON {
/**
* Check if the app is enabled, send json error msg if not
@@ -42,7 +42,7 @@ class OC_JSON{
* @suppress PhanDeprecatedFunction
*/
public static function checkAppEnabled($app) {
- if(!\OC::$server->getAppManager()->isEnabledForUser($app)) {
+ if (!\OC::$server->getAppManager()->isEnabledForUser($app)) {
$l = \OC::$server->getL10N('lib');
self::error([ 'data' => [ 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ]]);
exit();
@@ -56,7 +56,7 @@ class OC_JSON{
*/
public static function checkLoggedIn() {
$twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager();
- if(!\OC::$server->getUserSession()->isLoggedIn()
+ if (!\OC::$server->getUserSession()->isLoggedIn()
|| $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) {
$l = \OC::$server->getL10N('lib');
http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED);
@@ -71,12 +71,12 @@ class OC_JSON{
* @suppress PhanDeprecatedFunction
*/
public static function callCheck() {
- if(!\OC::$server->getRequest()->passesStrictCookieCheck()) {
+ if (!\OC::$server->getRequest()->passesStrictCookieCheck()) {
header('Location: '.\OC::$WEBROOT);
exit();
}
- if(!\OC::$server->getRequest()->passesCSRFCheck()) {
+ if (!\OC::$server->getRequest()->passesCSRFCheck()) {
$l = \OC::$server->getL10N('lib');
self::error([ 'data' => [ 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ]]);
exit();
@@ -89,7 +89,7 @@ class OC_JSON{
* @suppress PhanDeprecatedFunction
*/
public static function checkAdminUser() {
- if(!OC_User::isAdminUser(OC_User::getUser())) {
+ if (!OC_User::isAdminUser(OC_User::getUser())) {
$l = \OC::$server->getL10N('lib');
self::error([ 'data' => [ 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ]]);
exit();
diff --git a/lib/private/legacy/OC_Response.php b/lib/private/legacy/OC_Response.php
index 45fea27d61d..bbeb6258109 100644
--- a/lib/private/legacy/OC_Response.php
+++ b/lib/private/legacy/OC_Response.php
@@ -94,7 +94,7 @@ class OC_Response {
// Send fallback headers for installations that don't have the possibility to send
// custom headers on the webserver side
- if(getenv('modHeadersAvailable') !== 'true') {
+ if (getenv('modHeadersAvailable') !== 'true') {
header('Referrer-Policy: no-referrer'); // https://www.w3.org/TR/referrer-policy/
header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE
header('X-Download-Options: noopen'); // https://msdn.microsoft.com/en-us/library/jj542450(v=vs.85).aspx
@@ -104,5 +104,4 @@ class OC_Response {
header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters
}
}
-
}
diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php
index 08f23b55a0f..736011b4359 100644
--- a/lib/private/legacy/OC_Template.php
+++ b/lib/private/legacy/OC_Template.php
@@ -99,7 +99,7 @@ class OC_Template extends \OC\Template\Base {
* @param string $renderAs
*/
public static function initTemplateEngine($renderAs) {
- if (self::$initTemplateEngineFirstRun){
+ if (self::$initTemplateEngineFirstRun) {
//apps that started before the template initialization can load their own scripts/styles
//so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
@@ -130,7 +130,6 @@ class OC_Template extends \OC\Template\Base {
self::$initTemplateEngineFirstRun = false;
}
-
}
@@ -146,7 +145,7 @@ class OC_Template extends \OC\Template\Base {
*/
protected function findTemplate($theme, $app, $name) {
// Check if it is a app template or not.
- if($app !== '') {
+ if ($app !== '') {
$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
} else {
$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
@@ -182,10 +181,10 @@ class OC_Template extends \OC\Template\Base {
public function fetchPage($additionalParams = null) {
$data = parent::fetchPage($additionalParams);
- if($this->renderAs) {
+ if ($this->renderAs) {
$page = new TemplateLayout($this->renderAs, $this->app);
- if(is_array($additionalParams)) {
+ if (is_array($additionalParams)) {
foreach ($additionalParams as $key => $value) {
$page->assign($key, $value);
}
@@ -193,12 +192,12 @@ class OC_Template extends \OC\Template\Base {
// Add custom headers
$headers = '';
- foreach(OC_Util::$headers as $header) {
+ foreach (OC_Util::$headers as $header) {
$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) {
$headers .= ' defer';
}
- foreach($header['attributes'] as $name=>$value) {
+ foreach ($header['attributes'] as $name=>$value) {
$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
}
if ($header['text'] !== null) {
@@ -240,7 +239,7 @@ class OC_Template extends \OC\Template\Base {
*/
public static function printUserPage($application, $name, $parameters = []) {
$content = new OC_Template($application, $name, "user");
- foreach($parameters as $key => $value) {
+ foreach ($parameters as $key => $value) {
$content->assign($key, $value);
}
print $content->printPage();
@@ -255,7 +254,7 @@ class OC_Template extends \OC\Template\Base {
*/
public static function printAdminPage($application, $name, $parameters = []) {
$content = new OC_Template($application, $name, "admin");
- foreach($parameters as $key => $value) {
+ foreach ($parameters as $key => $value) {
$content->assign($key, $value);
}
return $content->printPage();
@@ -270,7 +269,7 @@ class OC_Template extends \OC\Template\Base {
*/
public static function printGuestPage($application, $name, $parameters = []) {
$content = new OC_Template($application, $name, $name === 'error' ? $name : 'guest');
- foreach($parameters as $key => $value) {
+ foreach ($parameters as $key => $value) {
$content->assign($key, $value);
}
return $content->printPage();
diff --git a/lib/private/legacy/OC_User.php b/lib/private/legacy/OC_User.php
index a9de5cdef9f..c61d99eee74 100644
--- a/lib/private/legacy/OC_User.php
+++ b/lib/private/legacy/OC_User.php
@@ -57,7 +57,6 @@ use OCP\ILogger;
* logout()
*/
class OC_User {
-
private static $_usedBackends = [];
private static $_setupedBackends = [];
@@ -161,7 +160,6 @@ class OC_User {
* @return bool
*/
public static function loginWithApache(\OCP\Authentication\IApacheBackend $backend) {
-
$uid = $backend->getCurrentUserId();
$run = true;
OC_Hook::emit("OC_User", "pre_login", ["run" => &$run, "uid" => $uid, 'backend' => $backend]);
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index 9322ef07a79..71f6edba0bf 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -302,7 +302,6 @@ class OC_Util {
//if we aren't logged in, there is no use to set up the filesystem
if ($user != "") {
-
$userDir = '/' . $user . '/files';
//jail the user into his "home" directory
@@ -382,7 +381,7 @@ class OC_Util {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}
$userQuota = $user->getQuota();
- if($userQuota === 'none') {
+ if ($userQuota === 'none') {
return \OCP\Files\FileInfo::SPACE_UNLIMITED;
}
return OC_Helper::computerFileSize($userQuota);
@@ -398,7 +397,6 @@ class OC_Util {
* @suppress PhanDeprecatedFunction
*/
public static function copySkeleton($userId, \OCP\Files\Folder $userDirectory) {
-
$plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
$userLang = \OC::$server->getL10NFactory()->findLanguage();
$skeletonDirectory = str_replace('{lang}', $userLang, $plainSkeletonDirectory);
@@ -450,7 +448,7 @@ class OC_Util {
// Verify if folder exists
$dir = opendir($source);
- if($dir === false) {
+ if ($dir === false) {
$logger->error(sprintf('Could not opendir "%s"', $source), ['app' => 'core']);
return;
}
@@ -464,7 +462,7 @@ class OC_Util {
} else {
$child = $target->newFile($file);
$sourceStream = fopen($source . '/' . $file, 'r');
- if($sourceStream === false) {
+ if ($sourceStream === false) {
$logger->error(sprintf('Could not fopen "%s"', $source . '/' . $file), ['app' => 'core']);
closedir($dir);
return;
@@ -663,7 +661,6 @@ class OC_Util {
* @return void
*/
private static function addExternalResource($application, $prepend, $path, $type = "script") {
-
if ($type === "style") {
if (!in_array($path, self::$styles)) {
if ($prepend === true) {
@@ -700,7 +697,6 @@ class OC_Util {
];
if ($prepend === true) {
array_unshift(self::$headers, $header);
-
} else {
self::$headers[] = $header;
}
@@ -750,7 +746,7 @@ class OC_Util {
}
// Check if config folder is writable.
- if(!OC_Helper::isReadOnlyConfigEnabled()) {
+ if (!OC_Helper::isReadOnlyConfigEnabled()) {
if (!is_writable(OC::$configDir) or !is_readable(OC::$configDir)) {
$errors[] = [
'error' => $l->t('Cannot write into "config" directory'),
@@ -890,15 +886,15 @@ class OC_Util {
}
}
- foreach($missingDependencies as $missingDependency) {
+ foreach ($missingDependencies as $missingDependency) {
$errors[] = [
'error' => $l->t('PHP module %s not installed.', [$missingDependency]),
'hint' => $moduleHint
];
$webServerRestart = true;
}
- foreach($invalidIniSettings as $setting) {
- if(is_bool($setting[1])) {
+ foreach ($invalidIniSettings as $setting) {
+ if (is_bool($setting[1])) {
$setting[1] = $setting[1] ? 'on' : 'off';
}
$errors[] = [
@@ -916,7 +912,7 @@ class OC_Util {
* TODO: Should probably be implemented in the above generic dependency
* check somehow in the long-term.
*/
- if($iniWrapper->getBool('mbstring.func_overload') !== null &&
+ if ($iniWrapper->getBool('mbstring.func_overload') !== null &&
$iniWrapper->getBool('mbstring.func_overload') === true) {
$errors[] = [
'error' => $l->t('mbstring.func_overload is set to "%s" instead of the expected value "0"', [$iniWrapper->getString('mbstring.func_overload')]),
@@ -924,7 +920,7 @@ class OC_Util {
];
}
- if(function_exists('xml_parser_create') &&
+ if (function_exists('xml_parser_create') &&
LIBXML_LOADED_VERSION < 20700) {
$version = LIBXML_LOADED_VERSION;
$major = floor($version/10000);
@@ -999,7 +995,7 @@ class OC_Util {
* @return array arrays with error messages and hints
*/
public static function checkDataDirectoryPermissions($dataDirectory) {
- if(\OC::$server->getConfig()->getSystemValue('check_data_directory_permissions', true) === false) {
+ if (\OC::$server->getConfig()->getSystemValue('check_data_directory_permissions', true) === false) {
return [];
}
$l = \OC::$server->getL10N('lib');
@@ -1116,7 +1112,7 @@ class OC_Util {
}
}
- if($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true') {
+ if ($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true') {
$location = $urlGenerator->getAbsoluteURL('/apps/' . $appId . '/');
} else {
$location = $urlGenerator->getAbsoluteURL('/index.php/apps/' . $appId . '/');
@@ -1226,7 +1222,6 @@ class OC_Util {
* @throws \OC\HintException If the test file can't get written.
*/
public function isHtaccessWorking(\OCP\IConfig $config) {
-
if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) {
return true;
}
@@ -1349,7 +1344,7 @@ class OC_Util {
* @return bool|string
*/
public static function normalizeUnicode($value) {
- if(Normalizer::isNormalized($value)) {
+ if (Normalizer::isNormalized($value)) {
return $value;
}
@@ -1466,5 +1461,4 @@ class OC_Util {
return preg_match(Request::USER_AGENT_IE, $_SERVER['HTTP_USER_AGENT']) === 1;
}
-
}
diff --git a/lib/private/legacy/template/functions.php b/lib/private/legacy/template/functions.php
index 83751db1e31..e2a1c476433 100644
--- a/lib/private/legacy/template/functions.php
+++ b/lib/private/legacy/template/functions.php
@@ -62,10 +62,10 @@ function emit_css_tag($href, $opts = '') {
* @param array $obj all the script information from template
*/
function emit_css_loading_tags($obj) {
- foreach($obj['cssfiles'] as $css) {
+ foreach ($obj['cssfiles'] as $css) {
emit_css_tag($css);
}
- foreach($obj['printcssfiles'] as $css) {
+ foreach ($obj['printcssfiles'] as $css) {
emit_css_tag($css, 'media="print"');
}
}
@@ -79,7 +79,7 @@ function emit_script_tag($src, $script_content='') {
$defer_str=' defer';
$s='<script nonce="' . \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() . '"';
if (!empty($src)) {
- // emit script tag for deferred loading from $src
+ // emit script tag for deferred loading from $src
$s.=$defer_str.' src="' . $src .'">';
} elseif (!empty($script_content)) {
// emit script tag for inline script from $script_content without defer (see MDN)
@@ -97,7 +97,7 @@ function emit_script_tag($src, $script_content='') {
* @param array $obj all the script information from template
*/
function emit_script_loading_tags($obj) {
- foreach($obj['jsfiles'] as $jsfile) {
+ foreach ($obj['jsfiles'] as $jsfile) {
emit_script_tag($jsfile, '');
}
if (!empty($obj['inline_ocjs'])) {
@@ -121,8 +121,8 @@ function print_unescaped($string) {
* if an array is given it will add all scripts
*/
function script($app, $file = null) {
- if(is_array($file)) {
- foreach($file as $f) {
+ if (is_array($file)) {
+ foreach ($file as $f) {
OC_Util::addScript($app, $f);
}
} else {
@@ -137,8 +137,8 @@ function script($app, $file = null) {
* if an array is given it will add all scripts
*/
function vendor_script($app, $file = null) {
- if(is_array($file)) {
- foreach($file as $f) {
+ if (is_array($file)) {
+ foreach ($file as $f) {
OC_Util::addVendorScript($app, $f);
}
} else {
@@ -153,8 +153,8 @@ function vendor_script($app, $file = null) {
* if an array is given it will add all styles
*/
function style($app, $file = null) {
- if(is_array($file)) {
- foreach($file as $f) {
+ if (is_array($file)) {
+ foreach ($file as $f) {
OC_Util::addStyle($app, $f);
}
} else {
@@ -169,8 +169,8 @@ function style($app, $file = null) {
* if an array is given it will add all styles
*/
function vendor_style($app, $file = null) {
- if(is_array($file)) {
- foreach($file as $f) {
+ if (is_array($file)) {
+ foreach ($file as $f) {
OC_Util::addVendorStyle($app, $f);
}
} else {
@@ -194,8 +194,8 @@ function translation($app) {
* if an array is given it will add all components
*/
function component($app, $file) {
- if(is_array($file)) {
- foreach($file as $f) {
+ if (is_array($file)) {
+ foreach ($file as $f) {
$url = link_to($app, 'component/' . $f . '.html');
OC_Util::addHeader('link', ['rel' => 'import', 'href' => $url]);
}
@@ -300,7 +300,7 @@ function relative_modified_date($timestamp, $fromTime = null, $dateOnly = false)
/** @var \OC\DateTimeFormatter $formatter */
$formatter = \OC::$server->query('DateTimeFormatter');
- if ($dateOnly){
+ if ($dateOnly) {
return $formatter->formatDateSpan($timestamp, $fromTime);
}
return $formatter->formatTimeSpan($timestamp, $fromTime);
@@ -321,7 +321,7 @@ function html_select_options($options, $selected, $params=[]) {
$label_name = $params['label'];
}
$html = '';
- foreach($options as $value => $label) {
+ foreach ($options as $value => $label) {
if ($value_name && is_array($label)) {
$value = $label[$value_name];
}