diff --git a/dev/View/Popup/OpenPgpImport.js b/dev/View/Popup/OpenPgpImport.js index 90f7e5c84..896cc0829 100644 --- a/dev/View/Popup/OpenPgpImport.js +++ b/dev/View/Popup/OpenPgpImport.js @@ -78,36 +78,30 @@ export class OpenPgpImportPopupView extends AbstractViewPopup { this.keyError(!keyTrimmed); this.keyErrorMessage(''); - if (!keyTrimmed) { - return; - } - - let match = null, - count = 30, - done = false; - // eslint-disable-next-line max-len - const reg = /[-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}[\s\S]+?[-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}/gi; - - do { - match = reg.exec(keyTrimmed); - if (match && 0 < count) { - if (match[0] && match[1] && match[2] && match[1] === match[2]) { - const GnuPG = this.saveGnuPG() && GnuPGUserStore.isSupported(), - backup = this.saveServer(); - PgpUserStore.importKey(this.key(), GnuPG, backup); - } - --count; + if (keyTrimmed) { + let match = null, + count = 30, done = false; - } else { - done = true; - } - } while (!done); + const GnuPG = this.saveGnuPG() && GnuPGUserStore.isSupported(), + backup = this.saveServer(), + // eslint-disable-next-line max-len + reg = /[-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}[\s\S]+?[-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}/gi; - if (this.keyError()) { - return; + do { + match = reg.exec(keyTrimmed); + if (match && 0 < count) { + if (match[0] && match[1] && match[2] && match[1] === match[2]) { + PgpUserStore.importKey(this.key(), GnuPG, backup); + } + --count; + done = false; + } else { + done = true; + } + } while (!done); + + this.close(); } - - this.close(); } onShow(key) {