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

All: Better handling of resources that are incorrectly flagged as encrypted

This commit is contained in:
Laurent Cozic
2018-04-22 14:33:12 +02:00
parent 4e3b8a06ea
commit d8ccc38d5b
2 changed files with 17 additions and 2 deletions

View File

@ -4,6 +4,7 @@ const { shim } = require('lib/shim.js');
const Setting = require('lib/models/Setting.js');
const MasterKey = require('lib/models/MasterKey');
const BaseItem = require('lib/models/BaseItem');
const JoplinError = require('lib/JoplinError');
const { _ } = require('lib/locale.js');
function hexPad(s, length) {
@ -322,7 +323,7 @@ class EncryptionService {
async decryptAbstract_(source, destination) {
const identifier = await source.read(5);
if (!this.isValidHeaderIdentifier(identifier)) throw new Error('Invalid encryption identifier. Data is not actually encrypted? ID was: ' + identifier);
if (!this.isValidHeaderIdentifier(identifier)) throw new JoplinError('Invalid encryption identifier. Data is not actually encrypted? ID was: ' + identifier, 'invalidIdentifier');
const mdSizeHex = await source.read(6);
const mdSize = parseInt(mdSizeHex, 16);
if (isNaN(mdSize) || !mdSize) throw new Error('Invalid header metadata size: ' + mdSizeHex);