Merge branch 'master' into preview-encoding

This commit is contained in:
El RIDO 2020-03-06 22:23:40 +01:00
commit c334d2d00d
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
6 changed files with 111 additions and 28 deletions

View File

@ -17,7 +17,7 @@ disabled:
- concat_without_spaces - concat_without_spaces
- declare_equal_normalize - declare_equal_normalize
- heredoc_to_nowdoc - heredoc_to_nowdoc
- method_argument_space - method_argument_space_strict
- new_with_braces - new_with_braces
- no_alternative_syntax - no_alternative_syntax
- phpdoc_align - phpdoc_align

View File

@ -3,6 +3,7 @@
* **1.4 (not yet released)** * **1.4 (not yet released)**
* CHANGED: Minimum required PHP version is 5.6, due to a change in the identicon library and to use php's native hash_equals() * CHANGED: Minimum required PHP version is 5.6, due to a change in the identicon library and to use php's native hash_equals()
* CHANGED: Upgrading libraries to: identicon 2.0.0 * CHANGED: Upgrading libraries to: identicon 2.0.0
* FIXED: Support custom expiration options in email function (#586)
* **1.3.3 (2020-02-16)** * **1.3.3 (2020-02-16)**
* CHANGED: Upgrading libraries to: DOMpurify 2.0.8 * CHANGED: Upgrading libraries to: DOMpurify 2.0.8
* CHANGED: Several translations got updated with missing messages * CHANGED: Several translations got updated with missing messages

View File

@ -172,9 +172,9 @@
"Notice:": "Notice:":
"Hinweis:", "Hinweis:",
"This link will expire after %s.": "This link will expire after %s.":
"Dieser Link wird in %s ablaufen.", "Dieser Link wird um %s ablaufen.",
"This link can only be accessed once, do not use back or refresh button in your browser.": "This link can only be accessed once, do not use back or refresh button in your browser.":
"Dieser Link kann nur einmal geöffnet werden, verwende nicht den \"Zurück\" oder \"Neu laden\" Knopf Deines Browsers.", "Dieser Link kann nur einmal geöffnet werden, verwende nicht den Zurück- oder Neu-laden-Knopf Deines Browsers.",
"Link:": "Link:":
"Link:", "Link:",
"Recipient may become aware of your timezone, convert time to UTC?": "Recipient may become aware of your timezone, convert time to UTC?":

View File

@ -209,6 +209,64 @@ jQuery.PrivateBin = (function($, RawDeflate) {
'=': '=' '=': '='
}; };
/**
* number of seconds in a minute
*
* @name Helper.minute
* @private
* @enum {number}
* @readonly
*/
const minute = 60;
/**
* number of seconds in an hour
*
* = 60 * 60 seconds
*
* @name Helper.minute
* @private
* @enum {number}
* @readonly
*/
const hour = 3600;
/**
* number of seconds in a day
*
* = 60 * 60 * 24 seconds
*
* @name Helper.day
* @private
* @enum {number}
* @readonly
*/
const day = 86400;
/**
* number of seconds in a month (30 days, an approximation)
*
* = 60 * 60 * 24 * 30 seconds
*
* @name Helper.month
* @private
* @enum {number}
* @readonly
*/
const month = 2592000;
/**
* number of seconds in a non-leap year
*
* = 60 * 60 * 24 * 365 seconds
*
* @name Helper.year
* @private
* @enum {number}
* @readonly
*/
const year = 31536000;
/** /**
* cache for script location * cache for script location
* *
@ -229,31 +287,67 @@ jQuery.PrivateBin = (function($, RawDeflate) {
me.secondsToHuman = function(seconds) me.secondsToHuman = function(seconds)
{ {
let v; let v;
if (seconds < 60) if (seconds < minute)
{ {
v = Math.floor(seconds); v = Math.floor(seconds);
return [v, 'second']; return [v, 'second'];
} }
if (seconds < 60 * 60) if (seconds < hour)
{ {
v = Math.floor(seconds / 60); v = Math.floor(seconds / minute);
return [v, 'minute']; return [v, 'minute'];
} }
if (seconds < 60 * 60 * 24) if (seconds < day)
{ {
v = Math.floor(seconds / (60 * 60)); v = Math.floor(seconds / hour);
return [v, 'hour']; return [v, 'hour'];
} }
// If less than 2 months, display in days: // If less than 2 months, display in days:
if (seconds < 60 * 60 * 24 * 60) if (seconds < (2 * month))
{ {
v = Math.floor(seconds / (60 * 60 * 24)); v = Math.floor(seconds / day);
return [v, 'day']; return [v, 'day'];
} }
v = Math.floor(seconds / (60 * 60 * 24 * 30)); v = Math.floor(seconds / month);
return [v, 'month']; return [v, 'month'];
}; };
/**
* converts a duration string into seconds
*
* The string is expected to be optional digits, followed by a time.
* Supported times are: min, hour, day, month, year, never
* Examples: 5min, 13hour, never
*
* @name Helper.durationToSeconds
* @function
* @param {String} duration
* @return {number}
*/
me.durationToSeconds = function(duration)
{
let pieces = duration.split(/\d+/),
factor = pieces[0] || 0,
timespan = pieces[1] || pieces[0];
switch (timespan)
{
case 'min':
return factor * minute;
case 'hour':
return factor * hour;
case 'day':
return factor * day;
case 'month':
return factor * month;
case 'year':
return factor * year;
case 'never':
return 0;
default:
return factor;
}
};
/** /**
* text range selection * text range selection
* *
@ -433,22 +527,10 @@ jQuery.PrivateBin = (function($, RawDeflate) {
* @return {Date} * @return {Date}
*/ */
me.calculateExpirationDate = function(initialDate, expirationDisplayStringOrSecondsToExpire) { me.calculateExpirationDate = function(initialDate, expirationDisplayStringOrSecondsToExpire) {
let expirationDate = new Date(initialDate); let expirationDate = new Date(initialDate),
secondsToExpiration = expirationDisplayStringOrSecondsToExpire;
const expirationDisplayStringToSecondsDict = {
'5min': 300,
'10min': 600,
'1hour': 3500,
'1day': 86400,
'1week': 604800,
'1month': 2592000,
'1year': 31536000,
'never': 0
};
let secondsToExpiration = expirationDisplayStringOrSecondsToExpire;
if (typeof expirationDisplayStringOrSecondsToExpire === 'string') { if (typeof expirationDisplayStringOrSecondsToExpire === 'string') {
secondsToExpiration = expirationDisplayStringToSecondsDict[expirationDisplayStringOrSecondsToExpire]; secondsToExpiration = me.durationToSeconds(expirationDisplayStringOrSecondsToExpire);
} }
if (typeof secondsToExpiration !== 'number') { if (typeof secondsToExpiration !== 'number') {

View File

@ -72,7 +72,7 @@ endif;
?> ?>
<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-QwcEKGuEmKtMguCO9pqNtUtZqq9b/tJ8gNr5qhY8hykq3zKTlDOvpZAmf6Rs8yH35Bz1ZdctUjj2qEWxT5aXCg==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-QwcEKGuEmKtMguCO9pqNtUtZqq9b/tJ8gNr5qhY8hykq3zKTlDOvpZAmf6Rs8yH35Bz1ZdctUjj2qEWxT5aXCg==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-JDQ0DFju78H5r/ZGC1n54tXnkhfijFRXxOvyWPZUTKlWKF2b1GVoPaS3eckgNcpb3MGvcYiMlhcg3xZNeyWtLQ==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-a6n/k3GMzkTTKsM1hyQ4+j8nIYuWB28ASR9vHvqOtEPzor4kp5ImcTRhOyNyolbeVDkuxnhducRAWnVCJwvjHg==" 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" />

View File

@ -50,7 +50,7 @@ endif;
?> ?>
<script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-QwcEKGuEmKtMguCO9pqNtUtZqq9b/tJ8gNr5qhY8hykq3zKTlDOvpZAmf6Rs8yH35Bz1ZdctUjj2qEWxT5aXCg==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/purify-2.0.8.js" integrity="sha512-QwcEKGuEmKtMguCO9pqNtUtZqq9b/tJ8gNr5qhY8hykq3zKTlDOvpZAmf6Rs8yH35Bz1ZdctUjj2qEWxT5aXCg==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/legacy.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-LYos+qXHIRqFf5ZPNphvtTB0cgzHUizu2wwcOwcwz/VIpRv9lpcBgPYz4uq6jx0INwCAj6Fbnl5HoKiLufS2jg==" crossorigin="anonymous"></script>
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-JDQ0DFju78H5r/ZGC1n54tXnkhfijFRXxOvyWPZUTKlWKF2b1GVoPaS3eckgNcpb3MGvcYiMlhcg3xZNeyWtLQ==" crossorigin="anonymous"></script> <script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-a6n/k3GMzkTTKsM1hyQ4+j8nIYuWB28ASR9vHvqOtEPzor4kp5ImcTRhOyNyolbeVDkuxnhducRAWnVCJwvjHg==" 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" />