summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorFlorin Peter <github@florin-peter.de>2013-05-27 20:44:38 +0200
committerFlorin Peter <github@florin-peter.de>2013-05-27 20:44:38 +0200
commit7224fc98b201feaa8fae99500ba9c262689563c9 (patch)
tree229a84dc47742fc035eca1f1b0f7c711f2b6c140 /apps
parent6075aff687d1f0fe81f3ddc48e872a8429bd8c61 (diff)
downloadnextcloud-server-7224fc98b201feaa8fae99500ba9c262689563c9.tar.gz
nextcloud-server-7224fc98b201feaa8fae99500ba9c262689563c9.zip
replace == with === and replace != with !==
Diffstat (limited to 'apps')
-rw-r--r--apps/files_encryption/ajax/adminrecovery.php2
-rw-r--r--apps/files_encryption/hooks/hooks.php10
-rwxr-xr-xapps/files_encryption/lib/crypt.php26
-rwxr-xr-xapps/files_encryption/lib/helper.php5
-rwxr-xr-xapps/files_encryption/lib/keymanager.php3
-rw-r--r--apps/files_encryption/lib/proxy.php18
-rw-r--r--apps/files_encryption/lib/session.php2
-rw-r--r--apps/files_encryption/lib/stream.php14
-rw-r--r--apps/files_encryption/lib/util.php30
9 files changed, 52 insertions, 58 deletions
diff --git a/apps/files_encryption/ajax/adminrecovery.php b/apps/files_encryption/ajax/adminrecovery.php
index 9375e27913a..4f3ac7fa173 100644
--- a/apps/files_encryption/ajax/adminrecovery.php
+++ b/apps/files_encryption/ajax/adminrecovery.php
@@ -29,7 +29,7 @@ if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === "1
// Disable recoveryAdmin
} elseif (
isset($_POST['adminEnableRecovery'])
- && 0 == $_POST['adminEnableRecovery']
+ && 0 === $_POST['adminEnableRecovery']
) {
$return = \OCA\Encryption\Helper::adminDisableRecovery($_POST['recoveryPassword']);
$action = "disable";
diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php
index c3371061356..6bac7debea2 100644
--- a/apps/files_encryption/hooks/hooks.php
+++ b/apps/files_encryption/hooks/hooks.php
@@ -145,9 +145,9 @@ class Hooks {
// Only attempt to change passphrase if server-side encryption
// is in use (client-side encryption does not have access to
// the necessary keys)
- if (Crypt::mode() == 'server') {
+ if (Crypt::mode() === 'server') {
- if ($params['uid'] == \OCP\User::getUser()) {
+ if ($params['uid'] === \OCP\User::getUser()) {
$view = new \OC_FilesystemView('/');
@@ -275,7 +275,7 @@ class Hooks {
$share = $util->getParentFromShare($params['id']);
//if parent is set, then this is a re-share action
- if ($share['parent'] != null) {
+ if ($share['parent'] !== null) {
// get the parent from current share
$parent = $util->getShareParent($params['parent']);
@@ -394,10 +394,10 @@ class Hooks {
}
// for group shares get a list of the group members
- if ($params['shareType'] == \OCP\Share::SHARE_TYPE_GROUP) {
+ if ($params['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) {
$userIds = \OC_Group::usersInGroup($params['shareWith']);
} else {
- if ($params['shareType'] == \OCP\Share::SHARE_TYPE_LINK) {
+ if ($params['shareType'] === \OCP\Share::SHARE_TYPE_LINK) {
$userIds = array($util->getPublicShareKeyId());
} else {
$userIds = array($params['shareWith']);
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php
index ef50dc0cd7a..56d5e082e49 100755
--- a/apps/files_encryption/lib/crypt.php
+++ b/apps/files_encryption/lib/crypt.php
@@ -92,7 +92,7 @@ class Crypt {
*/
public static function removePadding($padded) {
- if (substr($padded, -2) == 'xx') {
+ if (substr($padded, -2) === 'xx') {
$data = substr($padded, 0, -2);
@@ -132,7 +132,7 @@ class Crypt {
// Fetch identifier from start of metadata
$identifier = substr($meta, 0, 6);
- if ($identifier == '00iv00') {
+ if ($identifier === '00iv00') {
return true;
@@ -157,7 +157,7 @@ class Crypt {
$metadata = \OC\Files\Filesystem::getFileInfo($path);
// Return encryption status
- return isset($metadata['encrypted']) and ( bool )$metadata['encrypted'];
+ return isset($metadata['encrypted']) && ( bool )$metadata['encrypted'];
}
@@ -176,10 +176,9 @@ class Crypt {
// If a file is flagged with encryption in DB, but isn't a
// valid content + IV combination, it's probably using the
// legacy encryption system
- if (
- isset($metadata['encrypted'])
- and $metadata['encrypted'] === true
- and !self::isCatfileContent($data)
+ if (isset($metadata['encrypted'])
+ && $metadata['encrypted'] === true
+ && !self::isCatfileContent($data)
) {
return true;
@@ -268,8 +267,7 @@ class Crypt {
$encrypted = substr($catFile, 0, -22);
$split = array(
- 'encrypted' => $encrypted
- ,
+ 'encrypted' => $encrypted,
'iv' => $iv
);
@@ -464,6 +462,8 @@ class Crypt {
/**
* @brief Asymetrically encrypt a string using a public key
+ * @param $plainContent
+ * @param $publicKey
* @return string encrypted file
*/
public static function keyEncrypt($plainContent, $publicKey) {
@@ -476,6 +476,8 @@ class Crypt {
/**
* @brief Asymetrically decrypt a file using a private key
+ * @param $encryptedContent
+ * @param $privatekey
* @return string decrypted file
*/
public static function keyDecrypt($encryptedContent, $privatekey) {
@@ -548,7 +550,7 @@ class Crypt {
/**
* @brief Get the blowfish encryption handeler for a key
* @param $key string (optional)
- * @return Crypt_Blowfish blowfish object
+ * @return \Crypt_Blowfish blowfish object
*
* if the key is left out, the default handeler will be used
*/
@@ -586,8 +588,6 @@ class Crypt {
* @brief encrypts content using legacy blowfish system
* @param string $content the cleartext message you want to encrypt
* @param string $passphrase
- * @return
- * @internal param \OCA\Encryption\the $key encryption key (optional)
* @returns string encrypted content
*
* This function encrypts an content
@@ -604,8 +604,6 @@ class Crypt {
* @brief decrypts content using legacy blowfish system
* @param string $content the cleartext message you want to decrypt
* @param string $passphrase
- * @return string
- * @internal param \OCA\Encryption\the $key encryption key (optional)
* @return string cleartext content
*
* This function decrypts an content
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index b946f69513a..5fa4583263b 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -23,11 +23,8 @@
namespace OCA\Encryption;
- /**
- * @brief Class to manage registration of hooks an various helper methods
- */
/**
- * Class Helper
+ * @brief Class to manage registration of hooks an various helper methods
* @package OCA\Encryption
*/
class Helper {
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 49e76b2dc88..c7b431c3523 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -79,8 +79,7 @@ class Keymanager {
public static function getUserKeys(\OC_FilesystemView $view, $userId) {
return array(
- 'publicKey' => self::getPublicKey($view, $userId)
- ,
+ 'publicKey' => self::getPublicKey($view, $userId),
'privateKey' => self::getPrivateKey($view, $userId)
);
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index ae64e852aef..6d5b4fe5e34 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -52,8 +52,8 @@ class Proxy extends \OC_FileProxy {
if (is_null(self::$enableEncryption)) {
if (
- \OCP\Config::getAppValue('files_encryption', 'enable_encryption', 'true') == 'true'
- && Crypt::mode() == 'server'
+ \OCP\Config::getAppValue('files_encryption', 'enable_encryption', 'true') === 'true'
+ && Crypt::mode() === 'server'
) {
self::$enableEncryption = true;
@@ -204,7 +204,7 @@ class Proxy extends \OC_FileProxy {
// If data is a catfile
if (
- Crypt::mode() == 'server'
+ Crypt::mode() === 'server'
&& Crypt::isCatfileContent($data)
) {
@@ -222,7 +222,7 @@ class Proxy extends \OC_FileProxy {
$plainData = Crypt::symmetricDecryptFileContent($data, $plainKeyfile);
} elseif (
- Crypt::mode() == 'server'
+ Crypt::mode() === 'server'
&& isset($_SESSION['legacyenckey'])
&& Crypt::isEncryptedMeta($path)
) {
@@ -310,7 +310,7 @@ class Proxy extends \OC_FileProxy {
$path_f = implode('/', array_slice($path_split, 3));
// FIXME: handling for /userId/cache used by webdav for chunking. The cache chunks are NOT encrypted
- if (count($path_split) >= 2 && $path_split[2] == 'cache') {
+ if (isset($path_split) && $path_split[2] === 'cache') {
return $result;
}
@@ -326,7 +326,7 @@ class Proxy extends \OC_FileProxy {
// If file is already encrypted, decrypt using crypto protocol
if (
- Crypt::mode() == 'server'
+ Crypt::mode() === 'server'
&& $util->isEncryptedPath($path)
) {
@@ -339,8 +339,8 @@ class Proxy extends \OC_FileProxy {
} elseif (
self::shouldEncrypt($path)
- and $meta ['mode'] != 'r'
- and $meta['mode'] != 'rb'
+ and $meta ['mode'] !== 'r'
+ and $meta['mode'] !== 'rb'
) {
$result = fopen('crypt://' . $path_f, $meta['mode']);
}
@@ -452,7 +452,7 @@ class Proxy extends \OC_FileProxy {
$path_f = implode('/', array_slice($path_split, 3));
// only if file is on 'files' folder fix file size and sharing
- if (count($path_split) >= 2 && $path_split[2] == 'files' && $util->fixFileSize($path)) {
+ if (isset($path_split) && $path_split[2] === 'files' && $util->fixFileSize($path)) {
// get sharing app state
$sharingEnabled = \OCP\Share::isEnabled();
diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php
index ba52a43365f..52dd0b604e9 100644
--- a/apps/files_encryption/lib/session.php
+++ b/apps/files_encryption/lib/session.php
@@ -84,7 +84,7 @@ class Session {
}
if (\OCP\USER::getUser() === false
- || (isset($_GET['service']) && $_GET['service'] == 'files'
+ || (isset($_GET['service']) && $_GET['service'] === 'files'
&& isset($_GET['t']))
) {
// Disable encryption proxy to prevent recursive calls
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 88a06c09654..49e93730cd5 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -97,10 +97,10 @@ class Stream {
\OC_FileProxy::$enabled = false;
if (
- $mode == 'w'
- or $mode == 'w+'
- or $mode == 'wb'
- or $mode == 'wb+'
+ $mode === 'w'
+ or $mode === 'w+'
+ or $mode === 'wb'
+ or $mode === 'wb+'
) {
// We're writing a new file so start write counter with 0 bytes
@@ -152,7 +152,7 @@ class Stream {
$this->writeCache = '';
- if ($count != 8192) {
+ if ($count !== 8192) {
// $count will always be 8192 https://bugs.php.net/bug.php?id=21641
// This makes this function a lot simpler, but will break this class if the above 'bug' gets 'fixed'
@@ -425,8 +425,8 @@ class Stream {
$this->flush();
if (
- $this->meta['mode'] != 'r'
- and $this->meta['mode'] != 'rb'
+ $this->meta['mode'] !== 'r'
+ and $this->meta['mode'] !== 'rb'
and $this->size > 0
) {
// Disable encryption proxy to prevent recursive calls
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 8bd44d4e11d..5840b354a22 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -128,7 +128,7 @@ class Util {
// if we are anonymous/public
if ($this->userId === false
- || (isset($_GET['service']) && $_GET['service'] == 'files' && isset($_GET['t']))
+ || (isset($_GET['service']) && $_GET['service'] === 'files' && isset($_GET['t']))
) {
$this->userId = $this->publicShareKeyId;
@@ -384,7 +384,7 @@ class Util {
// we handle them
\OC_FileProxy::$enabled = false;
- if ($found == false) {
+ if ($found === false) {
$found = array(
'plain' => array(),
'encrypted' => array(),
@@ -400,8 +400,8 @@ class Util {
while (false !== ($file = readdir($handle))) {
if (
- $file != "."
- && $file != ".."
+ $file !== "."
+ && $file !== ".."
) {
$filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
@@ -571,7 +571,7 @@ class Util {
$pathSplit = explode('/', $path);
$pathRelative = implode('/', array_slice($pathSplit, 3));
- if ($pathSplit[2] == 'files' && $this->view->file_exists($path) && $this->isEncryptedPath($path)) {
+ if (isset($pathSplit[2]) && $pathSplit[2] === 'files' && $this->view->file_exists($path) && $this->isEncryptedPath($path)) {
// get the size from filesystem
$fullPath = $this->view->getLocalFile($path);
@@ -665,7 +665,7 @@ class Util {
$trimmed = ltrim($path, '/');
$split = explode('/', $trimmed);
- if ($split[2] == "Shared") {
+ if (isset($split[2]) && $split[2] === 'Shared') {
return true;
@@ -871,8 +871,8 @@ class Util {
// Check that the user is encryption capable, or is the
// public system user 'ownCloud' (for public shares)
if (
- $user == $this->publicShareKeyId
- or $user == $this->recoveryKeyId
+ $user === $this->publicShareKeyId
+ or $user === $this->recoveryKeyId
or $util->ready()
) {
@@ -920,7 +920,7 @@ class Util {
// We need to decrypt the keyfile
// Has the file been shared yet?
if (
- $this->userId == $fileOwner
+ $this->userId === $fileOwner
&& !Keymanager::getShareKey($this->view, $this->userId, $filePath) // NOTE: we can't use isShared() here because it's a post share hook so it always returns true
) {
@@ -1051,7 +1051,7 @@ class Util {
}
// add current user if given
- if ($currentUserId != false) {
+ if ($currentUserId !== false) {
$userIds[] = $currentUserId;
@@ -1168,7 +1168,7 @@ class Util {
\OC\Files\Filesystem::initMountPoints($fileOwnerUid);
// If the file owner is the currently logged in user
- if ($fileOwnerUid == $this->userId) {
+ if ($fileOwnerUid === $this->userId) {
// Assume the path supplied is correct
$filename = $path;
@@ -1230,7 +1230,7 @@ class Util {
$path = $dir . $path;
- if ($c['type'] === "dir") {
+ if ($c['type'] === 'dir') {
$result = array_merge($result, $this->getAllFiles($path));
@@ -1419,7 +1419,7 @@ class Util {
foreach ($dirContent as $item) {
// get relative path from files_encryption/keyfiles/
$filePath = substr($item['path'], strlen('files_encryption/keyfiles'));
- if ($item['type'] == 'dir') {
+ if ($item['type'] === 'dir') {
$this->addRecoveryKeys($filePath . '/');
} else {
$session = new Session(new \OC_FilesystemView('/'));
@@ -1439,7 +1439,7 @@ class Util {
foreach ($dirContent as $item) {
// get relative path from files_encryption/keyfiles
$filePath = substr($item['path'], strlen('files_encryption/keyfiles'));
- if ($item['type'] == 'dir') {
+ if ($item['type'] === 'dir') {
$this->removeRecoveryKeys($filePath . '/');
} else {
$file = substr($filePath, 0, -4);
@@ -1505,7 +1505,7 @@ class Util {
$dirContent = $this->view->getDirectoryContent($this->keyfilesPath . $path);
foreach ($dirContent as $item) {
$filePath = substr($item['path'], 25);
- if ($item['type'] == 'dir') {
+ if ($item['type'] === 'dir') {
$this->recoverAllFiles($filePath . '/', $privateKey);
} else {
$file = substr($filePath, 0, -4);