Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit d11828c

Browse files
authored
Check that browserpass isn't using a copy action before using the clipboard (#6)
1 parent 8f635d8 commit d11828c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/background.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ chrome.runtime.onMessageExternal.addListener(function(request, sender) {
1818
return;
1919
}
2020

21+
// hydrate request
22+
if (!request.hasOwnProperty("version")) {
23+
// REMOVE this block once browserpass-extension-3.1 is fully deployed in prod.
24+
request.version = "3.0.12";
25+
request.action = "noop";
26+
}
27+
request.version = (version => {
28+
var [major, minor, patch] = version.split(".");
29+
return parseInt(major) * 1000000 + parseInt(minor) * 1000 + parseInt(patch);
30+
})(request.version);
31+
2132
// parse OTP object
2233
if (request.otp.key === null) {
2334
// this is an OTP URI, so extract the pieces
@@ -57,8 +68,10 @@ chrome.runtime.onMessageExternal.addListener(function(request, sender) {
5768
console.log(`Unsupported OTP type: ${otp.type}`);
5869
}
5970

60-
// generate code
61-
copyToClipboard(otp.generate());
71+
// copy to clipboard
72+
if (!request.action.match(/^copy[A-Z]*/)) {
73+
copyToClipboard(otp.generate());
74+
}
6275
});
6376

6477
/**

0 commit comments

Comments
 (0)