]> source.dussan.org Git - nextcloud-server.git/commitdiff
replace == with === and replace != with !==
authorFlorin Peter <github@florin-peter.de>
Mon, 27 May 2013 18:44:38 +0000 (20:44 +0200)
committerFlorin Peter <github@florin-peter.de>
Mon, 27 May 2013 18:44:38 +0000 (20:44 +0200)
apps/files_encryption/ajax/adminrecovery.php
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/crypt.php
apps/files_encryption/lib/helper.php
apps/files_encryption/lib/keymanager.php
apps/files_encryption/lib/proxy.php
apps/files_encryption/lib/session.php
apps/files_encryption/lib/stream.php
apps/files_encryption/lib/util.php

index 9375e27913a712bff846030a763aacdc285f2568..4f3ac7fa173ed4fa3b5e911ed26373549d5add55 100644 (file)
@@ -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";
index c337106135644157e1abbd30cbb7fe22cfb1020c..6bac7debea27e703f67b3d9d323e596562418275 100644 (file)
@@ -145,9 +145,9 @@ class Hooks {
                // Only attempt to change passphrase if server-side encryption\r
                // is in use (client-side encryption does not have access to \r
                // the necessary keys)\r
-               if (Crypt::mode() == 'server') {\r
+               if (Crypt::mode() === 'server') {\r
 \r
-                       if ($params['uid'] == \OCP\User::getUser()) {\r
+                       if ($params['uid'] === \OCP\User::getUser()) {\r
 \r
                                $view = new \OC_FilesystemView('/');\r
 \r
@@ -275,7 +275,7 @@ class Hooks {
 \r
                        $share = $util->getParentFromShare($params['id']);\r
                        //if parent is set, then this is a re-share action\r
-                       if ($share['parent'] != null) {\r
+                       if ($share['parent'] !== null) {\r
 \r
                                // get the parent from current share\r
                                $parent = $util->getShareParent($params['parent']);\r
@@ -394,10 +394,10 @@ class Hooks {
                        }\r
 \r
                        // for group shares get a list of the group members\r
-                       if ($params['shareType'] == \OCP\Share::SHARE_TYPE_GROUP) {\r
+                       if ($params['shareType'] === \OCP\Share::SHARE_TYPE_GROUP) {\r
                                $userIds = \OC_Group::usersInGroup($params['shareWith']);\r
                        } else {\r
-                               if ($params['shareType'] == \OCP\Share::SHARE_TYPE_LINK) {\r
+                               if ($params['shareType'] === \OCP\Share::SHARE_TYPE_LINK) {\r
                                        $userIds = array($util->getPublicShareKeyId());\r
                                } else {\r
                                        $userIds = array($params['shareWith']);\r
index ef50dc0cd7a47934d666db2723e5496cc6601679..56d5e082e49f4bdd1fcb54e843cd54fc17b07e60 100755 (executable)
@@ -92,7 +92,7 @@ class Crypt {
         */\r
        public static function removePadding($padded) {\r
 \r
-               if (substr($padded, -2) == 'xx') {\r
+               if (substr($padded, -2) === 'xx') {\r
 \r
                        $data = substr($padded, 0, -2);\r
 \r
@@ -132,7 +132,7 @@ class Crypt {
                // Fetch identifier from start of metadata\r
                $identifier = substr($meta, 0, 6);\r
 \r
-               if ($identifier == '00iv00') {\r
+               if ($identifier === '00iv00') {\r
 \r
                        return true;\r
 \r
@@ -157,7 +157,7 @@ class Crypt {
                $metadata = \OC\Files\Filesystem::getFileInfo($path);\r
 \r
                // Return encryption status\r
-               return isset($metadata['encrypted']) and ( bool )$metadata['encrypted'];\r
+               return isset($metadata['encrypted']) && ( bool )$metadata['encrypted'];\r
 \r
        }\r
 \r
@@ -176,10 +176,9 @@ class Crypt {
                // If a file is flagged with encryption in DB, but isn't a \r
                // valid content + IV combination, it's probably using the \r
                // legacy encryption system\r
-               if (\r
-                       isset($metadata['encrypted'])\r
-                       and $metadata['encrypted'] === true\r
-                               and !self::isCatfileContent($data)\r
+               if (isset($metadata['encrypted'])\r
+                       && $metadata['encrypted'] === true\r
+                       && !self::isCatfileContent($data)\r
                ) {\r
 \r
                        return true;\r
@@ -268,8 +267,7 @@ class Crypt {
                $encrypted = substr($catFile, 0, -22);\r
 \r
                $split = array(\r
-                       'encrypted' => $encrypted\r
-               ,\r
+                       'encrypted' => $encrypted,\r
                        'iv' => $iv\r
                );\r
 \r
@@ -464,6 +462,8 @@ class Crypt {
 \r
        /**\r
         * @brief Asymetrically encrypt a string using a public key\r
+        * @param $plainContent\r
+        * @param $publicKey\r
         * @return string encrypted file\r
         */\r
        public static function keyEncrypt($plainContent, $publicKey) {\r
@@ -476,6 +476,8 @@ class Crypt {
 \r
        /**\r
         * @brief Asymetrically decrypt a file using a private key\r
+        * @param $encryptedContent\r
+        * @param $privatekey\r
         * @return string decrypted file\r
         */\r
        public static function keyDecrypt($encryptedContent, $privatekey) {\r
@@ -548,7 +550,7 @@ class Crypt {
        /**\r
         * @brief Get the blowfish encryption handeler for a key\r
         * @param $key string (optional)\r
-        * @return Crypt_Blowfish blowfish object\r
+        * @return \Crypt_Blowfish blowfish object\r
         *\r
         * if the key is left out, the default handeler will be used\r
         */\r
@@ -586,8 +588,6 @@ class Crypt {
         * @brief encrypts content using legacy blowfish system\r
         * @param string $content the cleartext message you want to encrypt\r
         * @param string $passphrase\r
-        * @return\r
-        * @internal param \OCA\Encryption\the $key encryption key (optional)\r
         * @returns string encrypted content\r
         *\r
         * This function encrypts an content\r
@@ -604,8 +604,6 @@ class Crypt {
         * @brief decrypts content using legacy blowfish system\r
         * @param string $content the cleartext message you want to decrypt\r
         * @param string $passphrase\r
-        * @return string\r
-        * @internal param \OCA\Encryption\the $key encryption key (optional)\r
         * @return string cleartext content\r
         *\r
         * This function decrypts an content\r
index b946f69513a7da8b8c95faae25220d0e897fe074..5fa4583263bab454a4ba679224174ff461d7a290 100755 (executable)
 
 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 {
index 49e76b2dc880eddcb7069eca04e03355260baee8..c7b431c3523a31989020df9d0dafdcac46a3b531 100755 (executable)
@@ -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)
                );
 
index ae64e852aef5f385ee81fde7bf6bb9f2be6543d1..6d5b4fe5e34ba1a05c1bd0b744aebe352437bf68 100644 (file)
@@ -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();
index ba52a43365fdd4ad4a8be71dae9cab4a09aa2f62..52dd0b604e9d835c3e7229a0d9c56db2f5bc5b45 100644 (file)
@@ -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
index 88a06c09654665d3b48d6d58ae4d2bfe00402bef..49e93730cd527cee748d5907aad40806446e7bd0 100644 (file)
@@ -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
index 8bd44d4e11d6b6d92b715bee15c48eab141c0336..5840b354a226233964477213a147f29acbe2c466 100644 (file)
@@ -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);