settings: document code on when exactly the pubkey is regenerated
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details

The pubkey should not always be regenerated when a privatekey is
pasted. The reason is that on paste event is fired before the
privateKeyInput value is updated.

Added code comments on when the condition passes and should be save
to re-generate the pubkey.
pull/38/head
OFF0 1 year ago
parent d8f71b74ec
commit 0047c0bdc0
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -613,10 +613,10 @@ privateKeyInput.addEventListener('paste', (event) => {
if (pubKeyInput.value || !event.clipboardData) {
return;
}
if (privateKeyInput.value === '' || (
privateKeyInput.selectionStart === 0
if (privateKeyInput.value === '' || ( // either privatekey field is empty
privateKeyInput.selectionStart === 0 // or the whole text is selected and replaced with the clipboard
&& privateKeyInput.selectionEnd === privateKeyInput.value.length
)) {
)) { // only generate the pubkey if no data other than the text from clipboard will be used
try {
pubKeyInput.value = getPublicKey(event.clipboardData.getData('text'));
} catch(err) {} // settings form will call validKeys on input and display the error

Loading…
Cancel
Save