diff --git a/CHANGELOG.md b/CHANGELOG.md index a29ea4b..4c28003 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - The style has been entirely reworked using Bootstrap instead of Bulma +- It is now impossible to include the separator in the dedicated name ## [0.3.0] - 2023-08-25 diff --git a/src/views/MainView.vue b/src/views/MainView.vue index 0717963..2b106d7 100644 --- a/src/views/MainView.vue +++ b/src/views/MainView.vue @@ -29,15 +29,20 @@ const generatedAddr = computed(() => { const raw_account = accounts.value.find((e) => e.id == selectedAccountId.value); if (raw_account) { const account = fromRawAccount(raw_account); - var hasher = hmac.create(sha256, account.key); - hasher.update(account.localPart); - hasher.update(account.separator); - hasher.update(subAddrName.value); - const mac = hasher.digest(); - const offset = mac[mac.length - 1] & 0xf; - const reduced_mac = mac.slice(offset, offset + 5); - const code = base32Encode(reduced_mac, 'RFC4648', { padding: false }).toLowerCase(); - return `${account.localPart}${account.separator}${subAddrName.value}${account.separator}${code}@${account.domain}`; + if (subAddrName.value.indexOf(account.separator) != -1) { + subAddrName.value = subAddrName.value.replaceAll(account.separator, ''); + } + if (subAddrName.value) { + var hasher = hmac.create(sha256, account.key); + hasher.update(account.localPart); + hasher.update(account.separator); + hasher.update(subAddrName.value); + const mac = hasher.digest(); + const offset = mac[mac.length - 1] & 0xf; + const reduced_mac = mac.slice(offset, offset + 5); + const code = base32Encode(reduced_mac, 'RFC4648', { padding: false }).toLowerCase(); + return `${account.localPart}${account.separator}${subAddrName.value}${account.separator}${code}@${account.domain}`; + } } } return '';