Do not show error, when paste is deleted manually

Prior to this commit, if the paste has been deleted manually (clicking
on "delete paste" after creation) it tried to fetch the now deleted
paste and display an error. This makes, of course, no sense.
This commit is contained in:
rugk 2018-05-22 11:41:35 +02:00
parent 626b4450e3
commit 1bf910480b
No known key found for this signature in database
GPG Key ID: 05D40A636AFAB34D
3 changed files with 22 additions and 3 deletions

View File

@ -741,6 +741,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
me.getPasteId = function()
{
if (id === null) {
// Attention: This also returns the delete token inside of the ID, if it is specified
id = window.location.search.substring(1);
if (id === '') {
@ -749,7 +750,19 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
}
return id;
};
}
/**
* Returns true, when the URL has a delete token and the current call was used for deleting a paste.
*
* @name Model.hasDeleteToken
* @function
* @return {bool}
*/
me.hasDeleteToken = function()
{
return window.location.search.indexOf('deletetoken') !== -1;
}
/**
* return the deciphering key stored in anchor part of the URL
@ -4412,6 +4425,12 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
return me.newPaste();
}
// if delete token is passed (i.e. paste has been deleted by this access)
// there is no more stuf we need to do
if (Model.hasDeleteToken()) {
return;
}
// prevent bots from viewing a paste and potentially deleting data
// when burn-after-reading is set
// see https://github.com/elrido/ZeroBin/issues/11

View File

@ -75,7 +75,7 @@ if ($MARKDOWN):
<?php
endif;
?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-lBUTJhcAMgpb2i75GGQfmlJ7V8uOj/um1SQDRXcsvL0zFV7lsuw5IItfbUJ2/XHX0CIr2b3LY4A8nAiFLwTtKA==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-henYzZGF1ifJSsU7o85JGbuiq851+njzq4rgiK/Wva4Ry7N49PvdE4awVaEoFYd0W0pyaT3v+6cE1ZfO2NBtwQ==" 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]-->

View File

@ -54,7 +54,7 @@ if ($QRCODE):
<?php
endif;
?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-lBUTJhcAMgpb2i75GGQfmlJ7V8uOj/um1SQDRXcsvL0zFV7lsuw5IItfbUJ2/XHX0CIr2b3LY4A8nAiFLwTtKA==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-henYzZGF1ifJSsU7o85JGbuiq851+njzq4rgiK/Wva4Ry7N49PvdE4awVaEoFYd0W0pyaT3v+6cE1ZfO2NBtwQ==" 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]-->