mirror of https://github.com/keeweb/keeweb.git
fix #125: warning for kdb files
This commit is contained in:
parent
2b68ae1356
commit
32edbb5de9
|
@ -121,6 +121,10 @@ var Locale = {
|
|||
'Changes you make will not be saved back to file system. ' +
|
||||
'To get the file with your data, export it from settings.',
|
||||
openLocalFileDontShow: 'Don\'t show this again',
|
||||
openWrongFile: 'Bad file',
|
||||
openWrongFileBody: 'This file format is not supported. This app works with KeePass database format files (KDBX).',
|
||||
openKdbFileBody: 'You are opening an old version format file (KDB). This app supports only new format (KDBX), ' +
|
||||
'please use KeePass v2 to convert between them.',
|
||||
|
||||
detAttDownload: 'Shift-click attachment button to download or ',
|
||||
detAttDelToRemove: 'Delete to remove',
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
var Backbone = require('backbone'),
|
||||
kdbxweb = require('kdbxweb'),
|
||||
Keys = require('../const/keys'),
|
||||
Alerts = require('../comp/alerts'),
|
||||
SecureInput = require('../comp/secure-input'),
|
||||
|
@ -127,6 +128,9 @@ var OpenView = Backbone.View.extend({
|
|||
reader.onload = (function(e) {
|
||||
switch (this.reading) {
|
||||
case 'fileData':
|
||||
if (!this.checkOpenFileFormat(e.target.result)) {
|
||||
return;
|
||||
}
|
||||
this.params.id = null;
|
||||
this.params.fileData = e.target.result;
|
||||
this.params.name = file.name.replace(/\.\w+$/i, '');
|
||||
|
@ -166,6 +170,23 @@ var OpenView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
|
||||
checkOpenFileFormat: function(fileData) {
|
||||
var fileSig = new Uint32Array(fileData, 0, 2);
|
||||
if (fileSig[0] !== kdbxweb.Consts.Signatures.FileMagic) {
|
||||
Alerts.error({ header: Locale.openWrongFile, body: Locale.openWrongFileBody });
|
||||
return false;
|
||||
}
|
||||
if (fileSig[1] === kdbxweb.Consts.Signatures.Sig2Kdb) {
|
||||
Alerts.error({ header: Locale.openWrongFile, body: Locale.openKdbFileBody });
|
||||
return false;
|
||||
}
|
||||
if (fileSig[1] !== kdbxweb.Consts.Signatures.Sig2Kdbx) {
|
||||
Alerts.error({ header: Locale.openWrongFile, body: Locale.openWrongFileBody });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
displayOpenFile: function() {
|
||||
this.$el.addClass('open--file');
|
||||
this.$el.find('.open__settings-key-file').removeClass('hide');
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
"dropbox": "antelle/dropbox-js#0.10.6",
|
||||
"font-awesome": "~4.4.0",
|
||||
"install": "~1.0.4",
|
||||
"kdbxweb": "~0.3.7",
|
||||
"kdbxweb": "~0.3.8",
|
||||
"normalize.css": "~3.0.3",
|
||||
"pikaday": "~1.3.3",
|
||||
"FileSaver.js": "eligrey/FileSaver.js",
|
||||
|
|
|
@ -16,6 +16,7 @@ Storage providers, usability improvements
|
|||
`+` shortcuts while the app is in background
|
||||
`+` build for 32-bit linux
|
||||
`+` ability to import xml
|
||||
`+` warning for kdb files
|
||||
`-` fix #88: capslock indicator
|
||||
`-` fix file settings input behavior
|
||||
|
||||
|
|
Loading…
Reference in New Issue