ensure promises can be collected
This commit is contained in:
parent
35045bb69a
commit
a08fed1add
@ -4166,14 +4166,16 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||
*
|
||||
* @name PasteDecrypter.decryptPaste
|
||||
* @private
|
||||
* @async
|
||||
* @function
|
||||
* @param {object} paste - paste data in object form
|
||||
* @param {string} key
|
||||
* @param {string} password
|
||||
* @param {bool} ignoreError - ignore decryption errors iof set to true
|
||||
* @throws {string}
|
||||
* @return {Promise}
|
||||
*/
|
||||
function decryptPaste(paste, key, password, ignoreError)
|
||||
async function decryptPaste(paste, key, password, ignoreError)
|
||||
{
|
||||
let decyptionPromise;
|
||||
if (ignoreError === true) {
|
||||
@ -4182,7 +4184,7 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||
decyptionPromise = decryptOrPromptPassword(key, password, paste.data);
|
||||
}
|
||||
|
||||
decyptionPromise.then((plaintext) => {
|
||||
return decyptionPromise.then((plaintext) => {
|
||||
if (plaintext !== false) {
|
||||
// on success show paste
|
||||
PasteViewer.setFormat(paste.meta.formatter);
|
||||
@ -4200,13 +4202,15 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||
*
|
||||
* @name PasteDecrypter.decryptAttachment
|
||||
* @private
|
||||
* @async
|
||||
* @function
|
||||
* @param {object} paste - paste data in object form
|
||||
* @param {string} key
|
||||
* @param {string} password
|
||||
* @throws {string}
|
||||
* @return {Promise}
|
||||
*/
|
||||
function decryptAttachment(paste, key, password)
|
||||
async function decryptAttachment(paste, key, password)
|
||||
{
|
||||
let attachmentPromise = decryptOrPromptPassword(key, password, paste.attachment);
|
||||
let attachmentNamePromise = decryptOrPromptPassword(key, password, paste.attachmentname);
|
||||
@ -4216,7 +4220,7 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||
attachmentNamePromise.catch((err) => {
|
||||
displayDecryptionError('failed to decipher attachment name: ' + err);
|
||||
})
|
||||
Promise.all([attachmentPromise, attachmentNamePromise]).then((results) => {
|
||||
return Promise.all([attachmentPromise, attachmentNamePromise]).then((results) => {
|
||||
if (!results.some((result) => {
|
||||
return result === false;
|
||||
})) {
|
||||
@ -4231,12 +4235,14 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||
*
|
||||
* @name PasteDecrypter.decryptComments
|
||||
* @private
|
||||
* @async
|
||||
* @function
|
||||
* @param {object} paste - paste data in object form
|
||||
* @param {string} key
|
||||
* @param {string} password
|
||||
* @return {Promise}
|
||||
*/
|
||||
function decryptComments(paste, key, password)
|
||||
async function decryptComments(paste, key, password)
|
||||
{
|
||||
// remove potential previous discussion
|
||||
DiscussionViewer.prepareNewDiscussion();
|
||||
@ -4248,7 +4254,7 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||
CryptTool.decipher(key, password, paste.comments[i].data)
|
||||
);
|
||||
}
|
||||
Promise.all(commentDecryptionPromises).then((plaintexts) => {
|
||||
return Promise.all(commentDecryptionPromises).then((plaintexts) => {
|
||||
for (var i = 0; i < paste.comments.length; ++i) {
|
||||
if (plaintexts[i] === false) {
|
||||
continue;
|
||||
@ -4333,7 +4339,7 @@ jQuery.PrivateBin = (function($, sjcl, RawDeflate) {
|
||||
|
||||
// if the discussion is opened on this paste, display it
|
||||
if (paste.meta.opendiscussion) {
|
||||
decrytionPromises(decryptComments(paste, key, password));
|
||||
decrytionPromises.push(decryptComments(paste, key, password));
|
||||
}
|
||||
|
||||
Promise.all(decrytionPromises).then(() => {
|
||||
|
@ -71,7 +71,7 @@ if ($MARKDOWN):
|
||||
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/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-QoyJMD+9as5QQUHm4/mdiFvqHA5VvFqo+N5pn1xNFA6t5bpxS8dI1HwkFbgTQjp/cJrGqTXQ6tDDAiUixiGXNQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-d/XW7mxDbNK7y+vSpp547tr+HCKuf83N924B31rvy5RYwa2i0CDcLRDo1WZ2HRfqJT0Go52ksqifS2BYieKB+Q==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
@ -49,7 +49,7 @@ if ($MARKDOWN):
|
||||
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/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-QoyJMD+9as5QQUHm4/mdiFvqHA5VvFqo+N5pn1xNFA6t5bpxS8dI1HwkFbgTQjp/cJrGqTXQ6tDDAiUixiGXNQ==" crossorigin="anonymous"></script>
|
||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-d/XW7mxDbNK7y+vSpp547tr+HCKuf83N924B31rvy5RYwa2i0CDcLRDo1WZ2HRfqJT0Go52ksqifS2BYieKB+Q==" crossorigin="anonymous"></script>
|
||||
<!--[if lt IE 10]>
|
||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||
<![endif]-->
|
||||
|
Loading…
Reference in New Issue
Block a user