From 1669b5258acf194d6af1e81f8ea1ca8115dfa5ab Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Thu, 25 Jan 2018 23:01:18 +0000 Subject: [PATCH] Fixed detection of encrypted item --- CliClient/app/command-e2ee.js | 3 ++- README.md | 4 ++-- ReactNativeClient/lib/services/EncryptionService.js | 5 +++-- docs/index.html | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CliClient/app/command-e2ee.js b/CliClient/app/command-e2ee.js index 2bf4c092c..2313d2ae5 100644 --- a/CliClient/app/command-e2ee.js +++ b/CliClient/app/command-e2ee.js @@ -131,7 +131,6 @@ class Command extends BaseCommand { } else if (stat.isDirectory()) { continue; } else { - itemCount++; const content = await fs.readFile(fullPath, 'utf8'); const item = await BaseItem.unserialize(content); const ItemClass = BaseItem.itemClass(item); @@ -141,6 +140,8 @@ class Command extends BaseCommand { continue; } + itemCount++; + const isEncrypted = await EncryptionService.instance().itemIsEncrypted(item); if (isEncrypted) { diff --git a/README.md b/README.md index f82c1e0d8..07f272172 100644 --- a/README.md +++ b/README.md @@ -91,12 +91,12 @@ Currently, synchronisation is possible with Nextcloud and OneDrive (by default) ## Nextcloud synchronisation -On the **desktop application** or **mobile application**, go to the config screen and select Nextcloud as the synchronisation target. Then input [the WebDAV URL](https://docs.nextcloud.com/server/9/user_manual/files/access_webdav.html), this is normally `https://example.com/nextcloud/remote.php/dav/files/USERNAME/` (make sure to replace USERNAME by your Nextcloud username), and set the username and password. +On the **desktop application** or **mobile application**, go to the config screen and select Nextcloud as the synchronisation target. Then input [the WebDAV URL](https://docs.nextcloud.com/server/9/user_manual/files/access_webdav.html), this is normally `https://example.com/nextcloud/remote.php/dav/files/USERNAME/Joplin` (make sure to create the "Joplin" directory in Nextcloud and to replace USERNAME by your Nextcloud username), and set the username and password. On the **terminal application**, you will need to set the `sync.target` config variable and all the `sync.5.path`, `sync.5.username` and `sync.5.password` config variables to, respectively the Nextcloud WebDAV URL, your username and your password. This can be done from the command line mode using: :config sync.target 5 - :config sync.5.path https://example.com/nextcloud/remote.php/dav/files/USERNAME/ + :config sync.5.path https://example.com/nextcloud/remote.php/dav/files/USERNAME/Joplin :config sync.5.username YOUR_USERNAME :config sync.5.password YOUR_PASSWORD diff --git a/ReactNativeClient/lib/services/EncryptionService.js b/ReactNativeClient/lib/services/EncryptionService.js index 7600c394e..96e8b38a9 100644 --- a/ReactNativeClient/lib/services/EncryptionService.js +++ b/ReactNativeClient/lib/services/EncryptionService.js @@ -507,7 +507,8 @@ class EncryptionService { } isValidHeaderIdentifier(id, ignoreTooLongLength = false) { - if (!ignoreTooLongLength && !id || id.length !== 5) return false; + if (!id) return false; + if (!ignoreTooLongLength && id.length !== 5) return false; return /JED\d\d/.test(id); } @@ -515,7 +516,7 @@ class EncryptionService { if (!item) throw new Error('No item'); const ItemClass = BaseItem.itemClass(item); if (!ItemClass.encryptionSupported()) return false; - return item.encryption_applied && this.isValidHeaderIdentifier(item.encryption_cipher_text); + return item.encryption_applied && this.isValidHeaderIdentifier(item.encryption_cipher_text, true); } async fileIsEncrypted(path) { diff --git a/docs/index.html b/docs/index.html index 8a700a0f5..f349109d5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -297,10 +297,10 @@ sudo ln -s ~/.joplin-bin/bin/joplin /usr/bin/joplin

One of the goals of Joplin was to avoid being tied to any particular company or service, whether it is Evernote, Google or Microsoft. As such the synchronisation is designed without any hard dependency to any particular service. Most of the synchronisation process is done at an abstract level and access to external services, such as Nextcloud or OneDrive, is done via lightweight drivers. It is easy to support new services by creating simple drivers that provide a filesystem-like interface, i.e. the ability to read, write, delete and list items. It is also simple to switch from one service to another or to even sync to multiple services at once. Each note, notebook, tags, as well as the relation between items is transmitted as plain text files during synchronisation, which means the data can also be moved to a different application, can be easily backed up, inspected, etc.

Currently, synchronisation is possible with Nextcloud and OneDrive (by default) or the local filesystem. A Dropbox one will also be available once this React Native bug is fixed. To setup synchronisation please follow the instructions below. After that, the application will synchronise in the background whenever it is running, or you can click on "Synchronise" to start a synchronisation manually.

Nextcloud synchronisation

-

On the desktop application or mobile application, go to the config screen and select Nextcloud as the synchronisation target. Then input the WebDAV URL, this is normally https://example.com/nextcloud/remote.php/dav/files/USERNAME/ (make sure to replace USERNAME by your Nextcloud username), and set the username and password.

+

On the desktop application or mobile application, go to the config screen and select Nextcloud as the synchronisation target. Then input the WebDAV URL, this is normally https://example.com/nextcloud/remote.php/dav/files/USERNAME/Joplin (make sure to create the "Joplin" directory in Nextcloud and to replace USERNAME by your Nextcloud username), and set the username and password.

On the terminal application, you will need to set the sync.target config variable and all the sync.5.path, sync.5.username and sync.5.password config variables to, respectively the Nextcloud WebDAV URL, your username and your password. This can be done from the command line mode using:

:config sync.target 5
-:config sync.5.path https://example.com/nextcloud/remote.php/dav/files/USERNAME/
+:config sync.5.path https://example.com/nextcloud/remote.php/dav/files/USERNAME/Joplin
 :config sync.5.username YOUR_USERNAME
 :config sync.5.password YOUR_PASSWORD
 

If synchronisation does not work, please consult the logs in the app profile directory - it is often due to a misconfigured URL or password. The log should indicate what the exact issue is.