1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Fixed detection of encrypted item

This commit is contained in:
Laurent Cozic
2018-01-25 23:01:18 +00:00
parent 5a9e0bfc26
commit 1669b5258a
4 changed files with 9 additions and 7 deletions

View File

@ -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) {