Skip to content

Commit

Permalink
Strip whitespace from BEFORE encrypting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rayquaza01 committed Dec 12, 2018
1 parent 1b20e6f commit 9fbe083
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions extension/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ async function submitKeyChange() {
console.log("Secret Key cannot be empty");
return;
}
DOM.key.value = DOM.key.value.replace(/\s/g, ""); // strip whitespace BEFORE encrypting to fix potential errors
res.otp_list[this.dataset.index].key = DOM.key.value;
if (password !== "") {
DOM.key.value = crypt(DOM.key.value, password);
}
res.otp_list[this.dataset.index].key = DOM.key.value.replace(/\s/g, "");
res.otp_list[this.dataset.index].key = DOM.key.value;
browser.storage.local.set(res);
DOM.key.value = "";
closeOverlays();
Expand All @@ -222,13 +224,14 @@ async function addSite() {
console.log("Secret Key cannot be empty");
return;
}
DOM.newKey.value = DOM.newKey.value.replace(/\s/g, ""); // strip spaces BEFORE encrypting to fix potential errors
if (password !== "") {
DOM.newKey.value = crypt(DOM.newKey.value, password);
}
var res = await browser.storage.local.get("otp_list");
var site = {
name: DOM.newName.value,
key: DOM.newKey.value.replace(/\s/g, "")
key: DOM.newKey.value
};
res.otp_list.push(site);
browser.storage.local.set(res);
Expand Down

0 comments on commit 9fbe083

Please sign in to comment.