Ver código fonte

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.
rugk 8 anos atrás
pai
commit
1bf910480b
3 arquivos alterados com 22 adições e 3 exclusões
  1. 20 1
      js/privatebin.js
  2. 1 1
      tpl/bootstrap.php
  3. 1 1
      tpl/page.php

+ 20 - 1
js/privatebin.js

@@ -741,6 +741,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
         me.getPasteId = function()
         me.getPasteId = function()
         {
         {
             if (id === null) {
             if (id === null) {
+                // Attention: This also returns the delete token inside of the ID, if it is specified
                 id = window.location.search.substring(1);
                 id = window.location.search.substring(1);
 
 
                 if (id === '') {
                 if (id === '') {
@@ -749,7 +750,19 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
             }
             }
 
 
             return id;
             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
          * return the deciphering key stored in anchor part of the URL
@@ -4412,6 +4425,12 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) {
                 return me.newPaste();
                 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
             // prevent bots from viewing a paste and potentially deleting data
             // when burn-after-reading is set
             // when burn-after-reading is set
             // see https://github.com/elrido/ZeroBin/issues/11
             // see https://github.com/elrido/ZeroBin/issues/11

+ 1 - 1
tpl/bootstrap.php

@@ -75,7 +75,7 @@ if ($MARKDOWN):
 <?php
 <?php
 endif;
 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]>
 		<!--[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]-->

+ 1 - 1
tpl/page.php

@@ -54,7 +54,7 @@ if ($QRCODE):
 <?php
 <?php
 endif;
 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]>
 		<!--[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]-->