pull/193/merge
R4SAS 7 years ago committed by GitHub
commit f8650bb0f0

@ -71,6 +71,11 @@ languageselection = false
; sha256 in HMAC for the deletion token
zerobincompatibility = false
; stay compatible with old PrivateBin versions, incompatible with standart ZLIB
; library, used for compress and decompress data. If enabled, will use
; rawdeflate-0.5.js and rawinflate-0.3.js instead pako.min.js
oldcompression = false
[expire]
; expire value that is selected per default
; make sure the value exists in [expire_options]

3
js/pako.min.js vendored

File diff suppressed because one or more lines are too long

@ -14,9 +14,9 @@
'use strict';
/** global: Base64 */
/** global: FileReader */
/** global: RawDeflate */
/** global: history */
/** global: navigator */
/** global: pako */
/** global: prettyPrint */
/** global: prettyPrintOne */
/** global: showdown */
@ -25,7 +25,16 @@
// Immediately start random number generator collector.
sjcl.random.startCollectors();
jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
if (typeof RawDeflate === 'undefined')
{
var compression = 'pako';
}
else
{
var compression = 'RawDeflate';
}
jQuery.PrivateBin = function($, compression, sjcl, Base64) {
/**
* static helper methods
*
@ -518,7 +527,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
*/
compress: function(message)
{
return Base64.toBase64( RawDeflate.deflate( Base64.utob(message) ) );
if (typeof RawDeflate === 'undefined')
{
return Base64.toBase64( pako.deflate( Base64.utob(message), { to: 'string' } ) );
}
else
{
return Base64.toBase64( RawDeflate.deflate( Base64.utob(message), { to: 'string' } ) );
}
},
/**
@ -531,7 +547,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
*/
decompress: function(data)
{
return Base64.btou( RawDeflate.inflate( Base64.fromBase64(data) ) );
if (typeof RawDeflate === 'undefined')
{
return Base64.btou( pako.inflate( Base64.fromBase64(data), { to: 'string' } ) );
}
else
{
return Base64.btou( RawDeflate.inflate( Base64.fromBase64(data), { to: 'string' } ) );
}
},
/**
@ -1850,4 +1873,4 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
filter: filter,
controller: controller
};
}(jQuery, sjcl, Base64, RawDeflate);
}(jQuery, compression, sjcl, Base64);

@ -53,6 +53,7 @@ class Configuration
'icon' => 'identicon',
'cspheader' => 'default-src \'none\'; manifest-src \'self\'; connect-src *; script-src \'self\'; style-src \'self\'; font-src \'self\'; img-src \'self\' data:; referrer no-referrer; sandbox allow-same-origin allow-scripts allow-forms allow-popups',
'zerobincompatibility' => false,
'oldcompression' => false,
),
'expire' => array(
'default' => '1week',

@ -451,6 +451,7 @@ class PrivateBin
$page->assign('PASSWORD', $this->_conf->getKey('password'));
$page->assign('FILEUPLOAD', $this->_conf->getKey('fileupload'));
$page->assign('ZEROBINCOMPATIBILITY', $this->_conf->getKey('zerobincompatibility'));
$page->assign('OLDCOMPRESSION', $this->_conf->getKey('oldcompression'));
$page->assign('LANGUAGESELECTION', $languageselection);
$page->assign('LANGUAGES', I18n::getLanguageLabels(I18n::getAvailableLanguages()));
$page->assign('EXPIRE', $expire);

@ -53,9 +53,17 @@ else:
<script type="text/javascript" src="js/base64-2.1.9.js" integrity="sha512-rbqAby7hObftbEoGQzkhUbEh5YkUn2MtekTLs4btvo2oly4CZ3DxhJzEh0u/rNzS54tcJdqi5Ug1ruugEd2U1g==" crossorigin="anonymous"></script>
<?php
endif;
if ($OLDCOMPRESSION):
?>
<script type="text/javascript" src="js/rawdeflate-0.5.js" integrity="sha512-tTdZ7qMr7tt5VQy4iCHu6/aGB12eRwbUy+AEI5rXntfsjcRfBeeqJloMsBU9FrGk1bIYLiuND/FhU42LO1bi0g==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/rawinflate-0.3.js" integrity="sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==" crossorigin="anonymous"></script>
<?php
else:
?>
<script type="text/javascript" src="js/pako.min.js" integrity="sha512-+0Qbu/wpfmGapJ83qFN6myWI3Dq0nT8uShfqM5KhsHIiPDpzVjSt7xDdDhLVUik5AkPDxh0vpsVtaNKa/WJqJQ==" crossorigin="anonymous"></script>
<?php
endif;
?>
<script type="text/javascript" src="js/bootstrap-3.3.7.js" integrity="sha512-iztkobsvnjKfAtTNdHkGVjAYTrrtlC7mGp/54c40wowO7LhURYl3gVzzcEqGl/qKXQltJ2HwMrdLcNUdo+N/RQ==" crossorigin="anonymous"></script>
<?php
if ($SYNTAXHIGHLIGHTING):
@ -69,7 +77,7 @@ if ($MARKDOWN):
<?php
endif;
?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-TETJUplZ4Gwfsyq+4b1auYItvlfa9BLoT+IzcQ6Xt2mlmMwKbso7b07/mTF2H2UqMy9I3j6nMAZGsPvIcAPzrQ==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-RjHIzS//2/wMv0qabFz7OC7PUow3uB1RiH9AqSac09ArgILhVK1snLUMe9xa42MKMOV8/a0eJ0l2q/4NVjKgiQ==" 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]-->

@ -32,10 +32,16 @@ else:
<script type="text/javascript" src="js/base64-2.1.9.js" integrity="sha512-rbqAby7hObftbEoGQzkhUbEh5YkUn2MtekTLs4btvo2oly4CZ3DxhJzEh0u/rNzS54tcJdqi5Ug1ruugEd2U1g==" crossorigin="anonymous"></script>
<?php
endif;
if ($OLDCOMPRESSION):
?>
<script type="text/javascript" src="js/rawdeflate-0.5.js" integrity="sha512-tTdZ7qMr7tt5VQy4iCHu6/aGB12eRwbUy+AEI5rXntfsjcRfBeeqJloMsBU9FrGk1bIYLiuND/FhU42LO1bi0g==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/rawinflate-0.3.js" integrity="sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==" crossorigin="anonymous"></script>
<?php
else:
?>
<script type="text/javascript" src="js/pako.min.js" integrity="sha512-+0Qbu/wpfmGapJ83qFN6myWI3Dq0nT8uShfqM5KhsHIiPDpzVjSt7xDdDhLVUik5AkPDxh0vpsVtaNKa/WJqJQ==" crossorigin="anonymous"></script>
<?php
endif;
if ($SYNTAXHIGHLIGHTING):
?>
<script type="text/javascript" src="js/prettify.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-m8iHxoN+Fe12xxFwWNdY/TS4KoFntHp29qY0xUzBnPd0bkKMOR/dFhEdTWydpt0b/fIXyhB+znGYUvgjfJ2RzQ==" crossorigin="anonymous"></script>
@ -47,7 +53,7 @@ if ($MARKDOWN):
<?php
endif;
?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-TETJUplZ4Gwfsyq+4b1auYItvlfa9BLoT+IzcQ6Xt2mlmMwKbso7b07/mTF2H2UqMy9I3j6nMAZGsPvIcAPzrQ==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-RjHIzS//2/wMv0qabFz7OC7PUow3uB1RiH9AqSac09ArgILhVK1snLUMe9xa42MKMOV8/a0eJ0l2q/4NVjKgiQ==" 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]-->

@ -49,6 +49,7 @@ class ViewTest extends PHPUnit_Framework_TestCase
$page->assign('PASSWORD', true);
$page->assign('FILEUPLOAD', false);
$page->assign('ZEROBINCOMPATIBILITY', false);
$page->assign('OLDCOMPRESSION', false);
$page->assign('NOTICE', 'example');
$page->assign('LANGUAGESELECTION', '');
$page->assign('LANGUAGES', I18n::getLanguageLabels(I18n::getAvailableLanguages()));

Loading…
Cancel
Save