|
@@ -1419,14 +1419,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
$passwordForm,
|
|
$passwordForm,
|
|
|
$passwordModal;
|
|
$passwordModal;
|
|
|
|
|
|
|
|
- var password = '',
|
|
|
|
|
- passwordCallback = null;
|
|
|
|
|
|
|
+ var password = '';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* ask the user for the password and set it
|
|
* ask the user for the password and set it
|
|
|
*
|
|
*
|
|
|
- * the callback set via setPasswordCallback is executed
|
|
|
|
|
- *
|
|
|
|
|
* @name Prompt.requestPassword()
|
|
* @name Prompt.requestPassword()
|
|
|
* @function
|
|
* @function
|
|
|
*/
|
|
*/
|
|
@@ -1438,7 +1435,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
backdrop: 'static',
|
|
backdrop: 'static',
|
|
|
keyboard: false
|
|
keyboard: false
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1453,10 +1449,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
password = newPassword;
|
|
password = newPassword;
|
|
|
-
|
|
|
|
|
- if (passwordCallback !== null) {
|
|
|
|
|
- passwordCallback();
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1474,18 +1466,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
return password;
|
|
return password;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * setsthe callback called when password is entered
|
|
|
|
|
- *
|
|
|
|
|
- * @name Prompt.setPasswordCallback
|
|
|
|
|
- * @function
|
|
|
|
|
- * @param {functions} setPasswordCallback
|
|
|
|
|
- */
|
|
|
|
|
- me.setPasswordCallback = function(callback)
|
|
|
|
|
- {
|
|
|
|
|
- passwordCallback = callback;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* submit a password in the modal dialog
|
|
* submit a password in the modal dialog
|
|
|
*
|
|
*
|
|
@@ -1495,17 +1475,15 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
*/
|
|
*/
|
|
|
function submitPasswordModal(event)
|
|
function submitPasswordModal(event)
|
|
|
{
|
|
{
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+
|
|
|
// get input
|
|
// get input
|
|
|
password = $passwordDecrypt.val();
|
|
password = $passwordDecrypt.val();
|
|
|
|
|
|
|
|
// hide modal
|
|
// hide modal
|
|
|
$passwordModal.modal('hide');
|
|
$passwordModal.modal('hide');
|
|
|
|
|
|
|
|
- if (passwordCallback !== null) {
|
|
|
|
|
- passwordCallback();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- event.preventDefault();
|
|
|
|
|
|
|
+ PasteDecrypter.run();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -3613,19 +3591,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
password = Prompt.getPassword();
|
|
password = Prompt.getPassword();
|
|
|
|
|
|
|
|
// if password is there, re-try
|
|
// if password is there, re-try
|
|
|
- if (password.length !== 0) {
|
|
|
|
|
- // recursive
|
|
|
|
|
- // note: an infinite loop is prevented as the previous if
|
|
|
|
|
- // clause checks whether a password is already set and ignores
|
|
|
|
|
- // errors when a password has been passed
|
|
|
|
|
- return decryptOrPromptPassword.apply(arguments);
|
|
|
|
|
|
|
+ if (password.length == 0) {
|
|
|
|
|
+ password = Prompt.requestPassword();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // trigger password request
|
|
|
|
|
- Prompt.requestPassword();
|
|
|
|
|
- // the callback (via setPasswordCallback()) should have been set
|
|
|
|
|
- // by a parent function
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ // recursive
|
|
|
|
|
+ // note: an infinite loop is prevented as the previous if
|
|
|
|
|
+ // clause checks whether a password is already set and ignores
|
|
|
|
|
+ // errors when a password has been passed
|
|
|
|
|
+ return decryptOrPromptPassword.apply(key, password, cipherdata);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// if all tries failed, we can only return an error
|
|
// if all tries failed, we can only return an error
|
|
@@ -3700,7 +3673,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
var attachmentName;
|
|
var attachmentName;
|
|
|
if (paste.attachmentname) {
|
|
if (paste.attachmentname) {
|
|
|
try {
|
|
try {
|
|
|
- var attachmentName = decryptOrPromptPassword(key, password, paste.attachmentname);
|
|
|
|
|
|
|
+ attachmentName = decryptOrPromptPassword(key, password, paste.attachmentname);
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
throw 'failed to decipher attachment name: ' + err
|
|
throw 'failed to decipher attachment name: ' + err
|
|
|
}
|
|
}
|
|
@@ -3755,6 +3728,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
*/
|
|
*/
|
|
|
me.run = function(paste)
|
|
me.run = function(paste)
|
|
|
{
|
|
{
|
|
|
|
|
+ Alert.hideMessages();
|
|
|
Alert.showLoading('Decrypting paste…', 0, 'cloud-download'); // @TODO icon maybe rotation-lock, but needs full Glyphicons
|
|
Alert.showLoading('Decrypting paste…', 0, 'cloud-download'); // @TODO icon maybe rotation-lock, but needs full Glyphicons
|
|
|
|
|
|
|
|
if (typeof paste === 'undefined') {
|
|
if (typeof paste === 'undefined') {
|
|
@@ -3771,10 +3745,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
|
|
|
|
|
// try to decrypt the paste
|
|
// try to decrypt the paste
|
|
|
try {
|
|
try {
|
|
|
- Prompt.setPasswordCallback(function () {
|
|
|
|
|
- me.run(paste);
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
// decrypt attachments
|
|
// decrypt attachments
|
|
|
if (paste.attachment) {
|
|
if (paste.attachment) {
|
|
|
// try to decrypt paste and if it fails (because the password is
|
|
// try to decrypt paste and if it fails (because the password is
|
|
@@ -3782,15 +3752,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|
|
if (!decryptAttachment(paste, key, password)) {
|
|
if (!decryptAttachment(paste, key, password)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ // ignore empty paste, as this is allowed when pasting attachments
|
|
|
|
|
+ decryptPaste(paste, key, password, true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ decryptPaste(paste, key, password);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // Deliberately ignores non-critical errors as this decryption
|
|
|
|
|
- // can also return an empty string and when this is done, the
|
|
|
|
|
- // decryption routine cannot differenciate this to an error.
|
|
|
|
|
- // As, however, the attachment could already be decrypted we
|
|
|
|
|
- // can continue here without showing an error, but just an empty
|
|
|
|
|
- // paste text.
|
|
|
|
|
- decryptPaste(paste, key, password, true);
|
|
|
|
|
} catch(err) {
|
|
} catch(err) {
|
|
|
Alert.hideLoading();
|
|
Alert.hideLoading();
|
|
|
|
|
|