Ver Fonte

Fix .getText of PasteViewer to return original text string

The issue was that I reused an existing module variable.

Now we have (yet another one) temp var for that.

Practically this fixes the "clone paste" button by using the original text.
rugk há 6 anos atrás
pai
commit
552e0cac3a
3 ficheiros alterados com 25 adições e 25 exclusões
  1. 23 23
      js/privatebin.js
  2. 1 1
      tpl/bootstrap.php
  3. 1 1
      tpl/page.php

+ 23 - 23
js/privatebin.js

@@ -18,14 +18,14 @@ jQuery.fn.draghover = function() {
     return this.each(function() {
     return this.each(function() {
         let collection = $(),
         let collection = $(),
             self = $(this);
             self = $(this);
-  
+
         self.on('dragenter', function(e) {
         self.on('dragenter', function(e) {
             if (collection.length === 0) {
             if (collection.length === 0) {
                 self.trigger('draghoverstart');
                 self.trigger('draghoverstart');
             }
             }
             collection = collection.add(e.target);
             collection = collection.add(e.target);
         });
         });
-  
+
         self.on('dragleave drop', function(e) {
         self.on('dragleave drop', function(e) {
             collection = collection.not(e.target);
             collection = collection.not(e.target);
             if (collection.length === 0) {
             if (collection.length === 0) {
@@ -375,7 +375,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
         };
         };
 
 
         /**
         /**
-         * formats the text that needs to be formatted, so DomPurify can properly escape it. 
+         * formats the text that needs to be formatted, so DomPurify can properly escape it.
          *
          *
          * @name   Helper.preformatTextForDomPurify
          * @name   Helper.preformatTextForDomPurify
          * @function
          * @function
@@ -543,7 +543,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * calculate expiration date given initial date and expiration period
          * calculate expiration date given initial date and expiration period
-         * 
+         *
          * @name   Helper.calculateExpirationDate
          * @name   Helper.calculateExpirationDate
          * @function
          * @function
          * @param  {Date} initialDate - may not be empty
          * @param  {Date} initialDate - may not be empty
@@ -556,7 +556,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
             if (typeof expirationDisplayStringOrSecondsToExpire === 'string') {
             if (typeof expirationDisplayStringOrSecondsToExpire === 'string') {
                 secondsToExpiration = me.durationToSeconds(expirationDisplayStringOrSecondsToExpire);
                 secondsToExpiration = me.durationToSeconds(expirationDisplayStringOrSecondsToExpire);
             }
             }
-            
+
             if (typeof secondsToExpiration !== 'number') {
             if (typeof secondsToExpiration !== 'number') {
                 throw new Error('Cannot calculate expiration date.');
                 throw new Error('Cannot calculate expiration date.');
             }
             }
@@ -2529,10 +2529,10 @@ jQuery.PrivateBin = (function($, RawDeflate) {
                 return;
                 return;
             }
             }
 
 
-            text = Helper.preformatTextForDomPurify(text, format);
-            
+            const processedText = Helper.preformatTextForDomPurify(text, format);
+
             // escape HTML entities, link URLs, sanitize
             // escape HTML entities, link URLs, sanitize
-            const escapedLinkedText = Helper.urls2links(text),
+            const escapedLinkedText = Helper.urls2links(processedText),
                   sanitizedLinkedText = DOMPurify.sanitize(
                   sanitizedLinkedText = DOMPurify.sanitize(
                     escapedLinkedText, {
                     escapedLinkedText, {
                         ALLOWED_TAGS: ['a'],
                         ALLOWED_TAGS: ['a'],
@@ -3763,11 +3763,11 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * Template Email body.
          * Template Email body.
-         * 
+         *
          * @name   TopNav.templateEmailBody
          * @name   TopNav.templateEmailBody
-         * @private 
-         * @param {string} expirationDateString 
-         * @param {bool} isBurnafterreading 
+         * @private
+         * @param {string} expirationDateString
+         * @param {bool} isBurnafterreading
          */
          */
         function templateEmailBody(expirationDateString, isBurnafterreading)
         function templateEmailBody(expirationDateString, isBurnafterreading)
         {
         {
@@ -3805,10 +3805,10 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * Trigger Email send.
          * Trigger Email send.
-         * 
+         *
          * @name   TopNav.triggerEmailSend
          * @name   TopNav.triggerEmailSend
-         * @private 
-         * @param {string} emailBody 
+         * @private
+         * @param {string} emailBody
          */
          */
         function triggerEmailSend(emailBody)
         function triggerEmailSend(emailBody)
         {
         {
@@ -4021,7 +4021,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * show the "email" button
          * show the "email" button
-         * 
+         *
          * @name   TopNav.showEmailbutton
          * @name   TopNav.showEmailbutton
          * @function
          * @function
          * @param {int|undefined} optionalRemainingTimeInSeconds
          * @param {int|undefined} optionalRemainingTimeInSeconds
@@ -4049,7 +4049,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * hide the "email" button
          * hide the "email" button
-         * 
+         *
          * @name   TopNav.hideEmailButton
          * @name   TopNav.hideEmailButton
          * @function
          * @function
          */
          */
@@ -4083,7 +4083,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * only hides the qr code button
          * only hides the qr code button
-         * 
+         *
          * @name   TopNav.hideQrCodeButton
          * @name   TopNav.hideQrCodeButton
          * @function
          * @function
          */
          */
@@ -4094,7 +4094,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * hide all irrelevant buttons when viewing burn after reading paste
          * hide all irrelevant buttons when viewing burn after reading paste
-         * 
+         *
          * @name   TopNav.hideBurnAfterReadingButtons
          * @name   TopNav.hideBurnAfterReadingButtons
          * @function
          * @function
          */
          */
@@ -4130,7 +4130,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * hides the custom attachment
          * hides the custom attachment
-         * 
+         *
          * @name  TopNav.hideCustomAttachment
          * @name  TopNav.hideCustomAttachment
          * @function
          * @function
          */
          */
@@ -4254,7 +4254,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * Highlight file upload
          * Highlight file upload
-         * 
+         *
          * @name  TopNav.highlightFileupload
          * @name  TopNav.highlightFileupload
          * @function
          * @function
          */
          */
@@ -4273,7 +4273,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * set the format on bootstrap templates in dropdown programmatically
          * set the format on bootstrap templates in dropdown programmatically
-         * 
+         *
          * @name    TopNav.setFormat
          * @name    TopNav.setFormat
          * @function
          * @function
          */
          */
@@ -4284,7 +4284,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
 
         /**
         /**
          * returns if attachment dropdown is readonly, not editable
          * returns if attachment dropdown is readonly, not editable
-         * 
+         *
          * @name   TopNav.isAttachmentReadonly
          * @name   TopNav.isAttachmentReadonly
          * @function
          * @function
          * @return {bool}
          * @return {bool}

+ 1 - 1
tpl/bootstrap.php

@@ -72,7 +72,7 @@ endif;
 ?>
 ?>
 		<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-x2Kev3A7fqc/QKCzRHoJ7qCiglgxXtY8WDUMPOUBI6jVueqRkRMGjP1IqD9iUWVuND81ckCCS27Br5M11tw0IA==" crossorigin="anonymous"></script>
 		<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-x2Kev3A7fqc/QKCzRHoJ7qCiglgxXtY8WDUMPOUBI6jVueqRkRMGjP1IqD9iUWVuND81ckCCS27Br5M11tw0IA==" crossorigin="anonymous"></script>
 		<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-3L/E22cdC3wDFXKM1i32bw4HdrfX14du2xswUKanOY6CLrD+e0hykmLvES+zfBKF1GFQFKr3OmdCVH2y+zHlsA==" crossorigin="anonymous"></script>
 		<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-3L/E22cdC3wDFXKM1i32bw4HdrfX14du2xswUKanOY6CLrD+e0hykmLvES+zfBKF1GFQFKr3OmdCVH2y+zHlsA==" crossorigin="anonymous"></script>
-		<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-5l2RuILQ59Go14jKwavtCpGEnUhzIkYyLF1ctlOaYxD5HVuBg4IAj5svkFQ4rirruhw88REZ6swax3CuLHeftg==" crossorigin="anonymous"></script>
+		<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-oFz+/zZ/kgeaA2BnbXgGhb74k9E13EiyA/TXGeWRoGo/7ZK+eScOHZfw8+GRNGqDq/d5EVMXwh9OcftfjHnNmA==" crossorigin="anonymous"></script>
 		<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
 		<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
 		<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
 		<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
 		<link rel="icon" type="image/png" href="img/favicon-16x16.png?<?php echo rawurlencode($VERSION); ?>" sizes="16x16" />
 		<link rel="icon" type="image/png" href="img/favicon-16x16.png?<?php echo rawurlencode($VERSION); ?>" sizes="16x16" />

+ 1 - 1
tpl/page.php

@@ -50,7 +50,7 @@ endif;
 ?>
 ?>
 		<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-x2Kev3A7fqc/QKCzRHoJ7qCiglgxXtY8WDUMPOUBI6jVueqRkRMGjP1IqD9iUWVuND81ckCCS27Br5M11tw0IA==" crossorigin="anonymous"></script>
 		<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-x2Kev3A7fqc/QKCzRHoJ7qCiglgxXtY8WDUMPOUBI6jVueqRkRMGjP1IqD9iUWVuND81ckCCS27Br5M11tw0IA==" crossorigin="anonymous"></script>
 		<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-3L/E22cdC3wDFXKM1i32bw4HdrfX14du2xswUKanOY6CLrD+e0hykmLvES+zfBKF1GFQFKr3OmdCVH2y+zHlsA==" crossorigin="anonymous"></script>
 		<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-3L/E22cdC3wDFXKM1i32bw4HdrfX14du2xswUKanOY6CLrD+e0hykmLvES+zfBKF1GFQFKr3OmdCVH2y+zHlsA==" crossorigin="anonymous"></script>
-		<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-5l2RuILQ59Go14jKwavtCpGEnUhzIkYyLF1ctlOaYxD5HVuBg4IAj5svkFQ4rirruhw88REZ6swax3CuLHeftg==" crossorigin="anonymous"></script>
+		<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-oFz+/zZ/kgeaA2BnbXgGhb74k9E13EiyA/TXGeWRoGo/7ZK+eScOHZfw8+GRNGqDq/d5EVMXwh9OcftfjHnNmA==" crossorigin="anonymous"></script>
 		<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
 		<link rel="apple-touch-icon" href="img/apple-touch-icon.png?<?php echo rawurlencode($VERSION); ?>" sizes="180x180" />
 		<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
 		<link rel="icon" type="image/png" href="img/favicon-32x32.png?<?php echo rawurlencode($VERSION); ?>" sizes="32x32" />
 		<link rel="icon" type="image/png" href="img/favicon-16x16.png?<?php echo rawurlencode($VERSION); ?>" sizes="16x16" />
 		<link rel="icon" type="image/png" href="img/favicon-16x16.png?<?php echo rawurlencode($VERSION); ?>" sizes="16x16" />