address decryptComments() async compatibility
This commit is contained in:
parent
ff8ec5a1a0
commit
100d955e1a
3 changed files with 30 additions and 36 deletions
|
@ -4169,16 +4169,14 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||||
*
|
*
|
||||||
* @name PasteDecrypter.decryptPaste
|
* @name PasteDecrypter.decryptPaste
|
||||||
* @private
|
* @private
|
||||||
* @async
|
|
||||||
* @function
|
* @function
|
||||||
* @param {object} paste - paste data in object form
|
* @param {object} paste - paste data in object form
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @param {bool} ignoreError - ignore decryption errors iof set to true
|
* @param {bool} ignoreError - ignore decryption errors iof set to true
|
||||||
* @return {bool} whether action was successful
|
|
||||||
* @throws {string}
|
* @throws {string}
|
||||||
*/
|
*/
|
||||||
async function decryptPaste(paste, key, password, ignoreError)
|
function decryptPaste(paste, key, password, ignoreError)
|
||||||
{
|
{
|
||||||
let decyptionPromise;
|
let decyptionPromise;
|
||||||
if (ignoreError === true) {
|
if (ignoreError === true) {
|
||||||
|
@ -4187,18 +4185,14 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||||
decyptionPromise = decryptOrPromptPassword(key, password, paste.data);
|
decyptionPromise = decryptOrPromptPassword(key, password, paste.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return decyptionPromise.then((plaintext) => {
|
decyptionPromise.then((plaintext) => {
|
||||||
if (plaintext === false) {
|
if (plaintext !== false) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// on success show paste
|
// on success show paste
|
||||||
PasteViewer.setFormat(paste.meta.formatter);
|
PasteViewer.setFormat(paste.meta.formatter);
|
||||||
PasteViewer.setText(plaintext);
|
PasteViewer.setText(plaintext);
|
||||||
// trigger to show the text (attachment loaded afterwards)
|
// trigger to show the text (attachment loaded afterwards)
|
||||||
PasteViewer.run();
|
PasteViewer.run();
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
throw 'failed to decipher paste text: ' + err;
|
throw 'failed to decipher paste text: ' + err;
|
||||||
});
|
});
|
||||||
|
@ -4209,15 +4203,13 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||||
*
|
*
|
||||||
* @name PasteDecrypter.decryptAttachment
|
* @name PasteDecrypter.decryptAttachment
|
||||||
* @private
|
* @private
|
||||||
* @async
|
|
||||||
* @function
|
* @function
|
||||||
* @param {object} paste - paste data in object form
|
* @param {object} paste - paste data in object form
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @return {bool} whether action was successful
|
|
||||||
* @throws {string}
|
* @throws {string}
|
||||||
*/
|
*/
|
||||||
async function decryptAttachment(paste, key, password)
|
function decryptAttachment(paste, key, password)
|
||||||
{
|
{
|
||||||
let attachmentPromise = decryptOrPromptPassword(key, password, paste.attachment);
|
let attachmentPromise = decryptOrPromptPassword(key, password, paste.attachment);
|
||||||
let attachmentNamePromise = decryptOrPromptPassword(key, password, paste.attachmentname);
|
let attachmentNamePromise = decryptOrPromptPassword(key, password, paste.attachmentname);
|
||||||
|
@ -4228,15 +4220,13 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||||
throw 'failed to decipher attachment name: ' + err;
|
throw 'failed to decipher attachment name: ' + err;
|
||||||
})
|
})
|
||||||
Promise.all([attachmentPromise, attachmentNamePromise]).then((results) => {
|
Promise.all([attachmentPromise, attachmentNamePromise]).then((results) => {
|
||||||
if (results.some((result) => {
|
if (!results.some((result) => {
|
||||||
return result === false;
|
return result === false;
|
||||||
})) {
|
})) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
AttachmentViewer.setAttachment(results[0], results[1]);
|
AttachmentViewer.setAttachment(results[0], results[1]);
|
||||||
AttachmentViewer.showAttachment();
|
AttachmentViewer.showAttachment();
|
||||||
return true;
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4248,26 +4238,30 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||||
* @param {object} paste - paste data in object form
|
* @param {object} paste - paste data in object form
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @return {bool} whether action was successful
|
|
||||||
*/
|
*/
|
||||||
function decryptComments(paste, key, password)
|
function decryptComments(paste, key, password)
|
||||||
{
|
{
|
||||||
// remove potentially previous discussion
|
// remove potential previous discussion
|
||||||
DiscussionViewer.prepareNewDiscussion();
|
DiscussionViewer.prepareNewDiscussion();
|
||||||
|
|
||||||
|
let commentDecryptionPromises = [];
|
||||||
// iterate over comments
|
// iterate over comments
|
||||||
|
for (var i = 0; i < paste.comments.length; ++i) {
|
||||||
|
commentDecryptionPromises.append(
|
||||||
|
CryptTool.decipher(key, password, paste.comments[i].data)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Promise.all(commentDecryptionPromises).then((plaintexts) => {
|
||||||
for (var i = 0; i < paste.comments.length; ++i) {
|
for (var i = 0; i < paste.comments.length; ++i) {
|
||||||
var comment = paste.comments[i];
|
var comment = paste.comments[i];
|
||||||
|
|
||||||
DiscussionViewer.addComment(
|
DiscussionViewer.addComment(
|
||||||
comment,
|
comment,
|
||||||
CryptTool.decipher(key, password, comment.data),
|
plaintexts[i],
|
||||||
comment.meta.nickname ? CryptTool.decipher(key, password, comment.meta.nickname) : ''
|
comment.meta.nickname ? CryptTool.decipher(key, password, comment.meta.nickname) : ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscussionViewer.finishDiscussion();
|
DiscussionViewer.finishDiscussion();
|
||||||
return true;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,7 +71,7 @@ if ($MARKDOWN):
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-koPew9AjZ8OBU64pQG50jLX+yTDw/i4smvV618aGUG1NX+LpEvAVhjQ7K7/Iprxr2ZHksz5BToLYf54G5IewHA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LONouflL+fHKsWtBahP1b1P0ZubtRPpNl8bh0VFrlbbux7N3JOgK28iWU7tVcB5daxHhgOHAFqagn2369a7gFg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -49,7 +49,7 @@ if ($MARKDOWN):
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.7.js" integrity="sha512-VnKJHLosO8z2ojNvWk9BEKYqnhZyWK9rM90FgZUUEp/PRnUqR5OLLKE0a3BkVmn7YgB7LXRrjHgFHQYKd6DAIA==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-koPew9AjZ8OBU64pQG50jLX+yTDw/i4smvV618aGUG1NX+LpEvAVhjQ7K7/Iprxr2ZHksz5BToLYf54G5IewHA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LONouflL+fHKsWtBahP1b1P0ZubtRPpNl8bh0VFrlbbux7N3JOgK28iWU7tVcB5daxHhgOHAFqagn2369a7gFg==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
Loading…
Reference in a new issue