Bladeren bron

- window.confirm fallbacks for page template removed
- page template removed from configuration-test-generator

Ribas160 1 jaar geleden
bovenliggende
commit
692e7af196
4 gewijzigde bestanden met toevoegingen van 48 en 87 verwijderingen
  1. 5 5
      bin/configuration-test-generator
  2. 42 79
      js/privatebin.js
  3. 0 2
      js/test/Prompt.js
  4. 1 1
      lib/Configuration.php

+ 5 - 5
bin/configuration-test-generator

@@ -164,14 +164,14 @@ new ConfigurationTestGenerator(array(
     ),
     'main/template' => array(
         array(
-            'setting' => 'page',
+            'setting' => 'bootstrap5',
             'tests'   => array(
                 array(
                     'type' => 'MatchesRegularExpression',
                     'args' => array(
-                        '#<link[^>]+type="text/css"[^>]+rel="stylesheet"[^>]+href="css/privatebin\.css\\?\d[\d\.]+\d+"[^>]*/>#',
+                        '#<link[^>]+type="text/css"[^>]+rel="stylesheet"[^>]+href="css/bootstrap5/privatebin\.css\\?\d[\d\.]+\d+"[^>]*/>#',
                         '$content',
-                        'outputs "page" stylesheet correctly',
+                        'outputs "bootstrap5" stylesheet correctly',
                     ),
                 ), array(
                     'type' => 'DoesNotMatchRegularExpression',
@@ -189,9 +189,9 @@ new ConfigurationTestGenerator(array(
                 array(
                     'type' => 'DoesNotMatchRegularExpression',
                     'args' => array(
-                        '#<link[^>]+type="text/css"[^>]+rel="stylesheet"[^>]+href="css/privatebin\.css\\?\d[\d\.]+\d+"[^>]*/>#',
+                        '#<link[^>]+type="text/css"[^>]+rel="stylesheet"[^>]+href="css/bootstrap5/privatebin\.css\\?\d[\d\.]+\d+"[^>]*/>#',
                         '$content',
-                        'removes "page" stylesheet correctly',
+                        'removes "bootstrap5" stylesheet correctly',
                     ),
                 ), array(
                     'type' => 'MatchesRegularExpression',

+ 42 - 79
js/privatebin.js

@@ -2319,26 +2319,19 @@ jQuery.PrivateBin = (function($, RawDeflate) {
         me.requestLoadConfirmation = function()
         {
             const $loadconfirmmodal = $('#loadconfirmmodal');
-            if ($loadconfirmmodal.length > 0) {
-                const $loadconfirmOpenNow = $loadconfirmmodal.find('#loadconfirm-open-now');
-                $loadconfirmOpenNow.off('click.loadPaste');
-                $loadconfirmOpenNow.on('click.loadPaste', PasteDecrypter.run);
-                const $loadconfirmClose = $loadconfirmmodal.find('.close');
-                $loadconfirmClose.off('click.close');
-                $loadconfirmClose.on('click.close', Controller.newPaste);
-                if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip.VERSION) {
-                    (new bootstrap.Modal($loadconfirmmodal[0])).show();
-                } else {
-                    $loadconfirmmodal.modal('show');
-                }
+
+            const $loadconfirmOpenNow = $loadconfirmmodal.find('#loadconfirm-open-now');
+            $loadconfirmOpenNow.off('click.loadPaste');
+            $loadconfirmOpenNow.on('click.loadPaste', PasteDecrypter.run);
+
+            const $loadconfirmClose = $loadconfirmmodal.find('.close');
+            $loadconfirmClose.off('click.close');
+            $loadconfirmClose.on('click.close', Controller.newPaste);
+
+            if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip.VERSION) {
+                (new bootstrap.Modal($loadconfirmmodal[0])).show();
             } else {
-                if (window.confirm(
-                    I18n._('This secret message can only be displayed once. Would you like to see it now?')
-                )) {
-                    PasteDecrypter.run();
-                } else {
-                    Controller.newPaste();
-                }
+                $loadconfirmmodal.modal('show');
             }
         }
 
@@ -2360,15 +2353,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
                 return;
             }
 
-            // fallback to old method for page template
-            password = prompt(I18n._('Please enter the password for this paste:'), '');
-            if (password === null) {
-                throw 'password prompt canceled';
-            }
-            if (password.length === 0) {
-                // recurse…
-                return me.requestPassword();
-            }
             PasteDecrypter.run();
         };
 
@@ -4193,59 +4177,42 @@ jQuery.PrivateBin = (function($, RawDeflate) {
             expirationDateRoundedToSecond.setUTCSeconds(0);
 
             const $emailconfirmmodal = $('#emailconfirmmodal');
-            if ($emailconfirmmodal.length > 0) {
-                if (expirationDate !== null) {
-                    const $emailconfirmTimezoneCurrent = $emailconfirmmodal.find('#emailconfirm-timezone-current');
-                    const $emailconfirmTimezoneUtc = $emailconfirmmodal.find('#emailconfirm-timezone-utc');
-                    let localeConfiguration = { dateStyle: 'long', timeStyle: 'long' };
-                    const bootstrap5EmailConfirmModal = typeof bootstrap !== 'undefined' && bootstrap.Tooltip.VERSION ?
-                        new bootstrap.Modal($emailconfirmmodal[0]) : null;
-
-                    function sendEmailAndHideModal() {
-                        const emailBody = templateEmailBody(
-                            // we don't use Date.prototype.toUTCString() because we would like to avoid GMT
-                            expirationDateRoundedToSecond.toLocaleString(
-                                [], localeConfiguration
-                            ), isBurnafterreading
-                        );
-                        if (bootstrap5EmailConfirmModal) {
-                            bootstrap5EmailConfirmModal.hide();
-                        } else {
-                            $emailconfirmmodal.modal('hide');
-                        }
-                        triggerEmailSend(emailBody);
-                    };
-
-                    $emailconfirmTimezoneCurrent.off('click.sendEmailCurrentTimezone');
-                    $emailconfirmTimezoneCurrent.on('click.sendEmailCurrentTimezone', sendEmailAndHideModal);
-                    $emailconfirmTimezoneUtc.off('click.sendEmailUtcTimezone');
-                    $emailconfirmTimezoneUtc.on('click.sendEmailUtcTimezone', () => {
-                        localeConfiguration.timeZone = 'UTC';
-                        sendEmailAndHideModal();
-                    });
+            if (expirationDate !== null) {
+                const $emailconfirmTimezoneCurrent = $emailconfirmmodal.find('#emailconfirm-timezone-current');
+                const $emailconfirmTimezoneUtc = $emailconfirmmodal.find('#emailconfirm-timezone-utc');
+                let localeConfiguration = { dateStyle: 'long', timeStyle: 'long' };
+                const bootstrap5EmailConfirmModal = typeof bootstrap !== 'undefined' && bootstrap.Tooltip.VERSION ?
+                    new bootstrap.Modal($emailconfirmmodal[0]) : null;
+
+                function sendEmailAndHideModal() {
+                    const emailBody = templateEmailBody(
+                        // we don't use Date.prototype.toUTCString() because we would like to avoid GMT
+                        expirationDateRoundedToSecond.toLocaleString(
+                            [], localeConfiguration
+                        ), isBurnafterreading
+                    );
                     if (bootstrap5EmailConfirmModal) {
-                        bootstrap5EmailConfirmModal.show();
+                        bootstrap5EmailConfirmModal.hide();
                     } else {
-                        $emailconfirmmodal.modal('show');
+                        $emailconfirmmodal.modal('hide');
                     }
+                    triggerEmailSend(emailBody);
+                };
+
+                $emailconfirmTimezoneCurrent.off('click.sendEmailCurrentTimezone');
+                $emailconfirmTimezoneCurrent.on('click.sendEmailCurrentTimezone', sendEmailAndHideModal);
+                $emailconfirmTimezoneUtc.off('click.sendEmailUtcTimezone');
+                $emailconfirmTimezoneUtc.on('click.sendEmailUtcTimezone', () => {
+                    localeConfiguration.timeZone = 'UTC';
+                    sendEmailAndHideModal();
+                });
+                if (bootstrap5EmailConfirmModal) {
+                    bootstrap5EmailConfirmModal.show();
                 } else {
-                    triggerEmailSend(templateEmailBody(null, isBurnafterreading));
+                    $emailconfirmmodal.modal('show');
                 }
             } else {
-                let emailBody = '';
-                if (expirationDate !== null) {
-                    const expirationDateString = window.confirm(
-                        I18n._('Recipient may become aware of your timezone, convert time to UTC?')
-                    ) ? expirationDateRoundedToSecond.toLocaleString(
-                        undefined,
-                        // we don't use Date.prototype.toUTCString() because we would like to avoid GMT
-                        { timeZone: 'UTC', dateStyle: 'long', timeStyle: 'long' }
-                    ) : expirationDateRoundedToSecond.toLocaleString();
-                    emailBody = templateEmailBody(expirationDateString, isBurnafterreading);
-                } else {
-                    emailBody = templateEmailBody(null, isBurnafterreading);
-                }
-                triggerEmailSend(emailBody);
+                triggerEmailSend(templateEmailBody(null, isBurnafterreading));
             }
         }
 
@@ -4728,13 +4695,9 @@ jQuery.PrivateBin = (function($, RawDeflate) {
 
             // bootstrap template drop down
             $('#language ul.dropdown-menu li a').click(setLanguage);
-            // page template drop down
-            $('#language select').change(setLanguage);
 
             // bootstrap template drop down
             $('#template ul.dropdown-menu li a').click(setTemplate);
-            // page template drop down
-            $('#template select').change(setTemplate);
 
             // bind events
             $burnAfterReading.change(changeBurnAfterReading);

+ 0 - 2
js/test/Prompt.js

@@ -2,8 +2,6 @@
 require('../common');
 
 describe('Prompt', function () {
-    // TODO: this does not test the prompt() fallback, since that isn't available
-    //       in nodejs -> replace the prompt in the "page" template with a modal
     describe('requestPassword & getPassword', function () {
         this.timeout(30000);
 

+ 1 - 1
lib/Configuration.php

@@ -118,7 +118,7 @@ class Configuration
             'js/kjua-0.9.0.js'       => 'sha512-CVn7af+vTMBd9RjoS4QM5fpLFEOtBCoB0zPtaqIDC7sF4F8qgUSRFQQpIyEDGsr6yrjbuOLzdf20tkHHmpaqwQ==',
             'js/legacy.js'           => 'sha512-UxW/TOZKon83n6dk/09GsYKIyeO5LeBHokxyIq+r7KFS5KMBeIB/EM7NrkVYIezwZBaovnyNtY2d9tKFicRlXg==',
             'js/prettify.js'         => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==',
-            'js/privatebin.js'       => 'sha512-i0l0rh+NCY8Oeg9SxzQREHin6egXJ6sdIC84RTEsBpBNhYGObv8QEdRng1dMERZmw4olVeXx2ZCkusTyT1G+SA==',
+            'js/privatebin.js'       => 'sha512-lP3oQM8eZ6HNCUUZC2HvmNTO3RRNw7WPCCWbVVr0e9DHvgprYr6tYtDYzmWdpD6rzjHOgekHhFMO8LIO9ufyug==',
             'js/purify-3.2.6.js'     => 'sha512-zqwL4OoBLFx89QPewkz4Lz5CSA2ktU+f31fuECkF0iK3Id5qd3Zpq5dMby8KwHjIEpsUgOqwF58cnmcaNem0EA==',
             'js/rawinflate-0.3.js'   => 'sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==',
             'js/showdown-2.1.0.js'   => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',