mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-07-22 14:30:41 -04:00
Merge pull request #1545 from PrivateBin/fixes
Fixes for zlib caching & handling undefined globals
This commit is contained in:
commit
964b4da50a
9 changed files with 30 additions and 10 deletions
|
@ -8,6 +8,8 @@
|
||||||
* CHANGED: Support for multiple file uploads (#1060)
|
* CHANGED: Support for multiple file uploads (#1060)
|
||||||
* CHANGED: Documented CSP change necessary to allow PDF attachment preview (#1552)
|
* CHANGED: Documented CSP change necessary to allow PDF attachment preview (#1552)
|
||||||
* FIXED: Hide Reply button in the discussions once clicked to avoid losing the text input (#1508)
|
* FIXED: Hide Reply button in the discussions once clicked to avoid losing the text input (#1508)
|
||||||
|
* FIXED: Bump zlib library suffix, ensuring cache refresh for WASM streaming change
|
||||||
|
* FIXED: Handle undefined globals in file based persisted values (#1544)
|
||||||
|
|
||||||
## 1.7.6 (2025-02-01)
|
## 1.7.6 (2025-02-01)
|
||||||
* ADDED: Ability to copy the paste by clicking the copy icon button or using the keyboard shortcut ctrl+c/cmd+c (#1390 & #12)
|
* ADDED: Ability to copy the paste by clicking the copy icon button or using the keyboard shortcut ctrl+c/cmd+c (#1390 & #12)
|
||||||
|
|
|
@ -11,7 +11,7 @@ global.WebCrypto = require('@peculiar/webcrypto').Crypto;
|
||||||
// application libraries to test
|
// application libraries to test
|
||||||
global.$ = global.jQuery = require('./jquery-3.7.1');
|
global.$ = global.jQuery = require('./jquery-3.7.1');
|
||||||
global.RawDeflate = require('./rawinflate-0.3').RawDeflate;
|
global.RawDeflate = require('./rawinflate-0.3').RawDeflate;
|
||||||
global.zlib = require('./zlib-1.3.1').zlib;
|
global.zlib = require('./zlib-1.3.1-1').zlib;
|
||||||
require('./prettify');
|
require('./prettify');
|
||||||
global.prettyPrint = window.PR.prettyPrint;
|
global.prettyPrint = window.PR.prettyPrint;
|
||||||
global.prettyPrintOne = window.PR.prettyPrintOne;
|
global.prettyPrintOne = window.PR.prettyPrintOne;
|
||||||
|
|
|
@ -123,7 +123,7 @@ class Configuration
|
||||||
'js/purify-3.2.6.js' => 'sha512-zqwL4OoBLFx89QPewkz4Lz5CSA2ktU+f31fuECkF0iK3Id5qd3Zpq5dMby8KwHjIEpsUgOqwF58cnmcaNem0EA==',
|
'js/purify-3.2.6.js' => 'sha512-zqwL4OoBLFx89QPewkz4Lz5CSA2ktU+f31fuECkF0iK3Id5qd3Zpq5dMby8KwHjIEpsUgOqwF58cnmcaNem0EA==',
|
||||||
'js/rawinflate-0.3.js' => 'sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==',
|
'js/rawinflate-0.3.js' => 'sha512-g8uelGgJW9A/Z1tB6Izxab++oj5kdD7B4qC7DHwZkB6DGMXKyzx7v5mvap2HXueI2IIn08YlRYM56jwWdm2ucQ==',
|
||||||
'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',
|
'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',
|
||||||
'js/zlib-1.3.1.js' => 'sha512-5bU9IIP4PgBrOKLZvGWJD4kgfQrkTz8Z3Iqeu058mbQzW3mCumOU6M3UVbVZU9rrVoVwaW4cZK8U8h5xjF88eQ==',
|
'js/zlib-1.3.1-1.js' => 'sha512-5bU9IIP4PgBrOKLZvGWJD4kgfQrkTz8Z3Iqeu058mbQzW3mCumOU6M3UVbVZU9rrVoVwaW4cZK8U8h5xjF88eQ==',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ class Filesystem extends AbstractData
|
||||||
case 'purge_limiter':
|
case 'purge_limiter':
|
||||||
return $this->_storeString(
|
return $this->_storeString(
|
||||||
$this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php',
|
$this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php',
|
||||||
'<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . $value . ';'
|
'<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . var_export($value, true) . ';'
|
||||||
);
|
);
|
||||||
case 'salt':
|
case 'salt':
|
||||||
return $this->_storeString(
|
return $this->_storeString(
|
||||||
|
@ -308,8 +308,10 @@ class Filesystem extends AbstractData
|
||||||
$file = $this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php';
|
$file = $this->_path . DIRECTORY_SEPARATOR . 'purge_limiter.php';
|
||||||
if (is_readable($file)) {
|
if (is_readable($file)) {
|
||||||
require $file;
|
require $file;
|
||||||
|
if (array_key_exists('purge_limiter', $GLOBALS)) {
|
||||||
return $GLOBALS['purge_limiter'];
|
return $GLOBALS['purge_limiter'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'salt':
|
case 'salt':
|
||||||
$file = $this->_path . DIRECTORY_SEPARATOR . 'salt.php';
|
$file = $this->_path . DIRECTORY_SEPARATOR . 'salt.php';
|
||||||
|
@ -324,11 +326,13 @@ class Filesystem extends AbstractData
|
||||||
$file = $this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php';
|
$file = $this->_path . DIRECTORY_SEPARATOR . 'traffic_limiter.php';
|
||||||
if (is_readable($file)) {
|
if (is_readable($file)) {
|
||||||
require $file;
|
require $file;
|
||||||
|
if (array_key_exists('traffic_limiter', $GLOBALS)) {
|
||||||
$this->_last_cache = $GLOBALS['traffic_limiter'];
|
$this->_last_cache = $GLOBALS['traffic_limiter'];
|
||||||
if (array_key_exists($key, $this->_last_cache)) {
|
if (array_key_exists($key, $this->_last_cache)) {
|
||||||
return $this->_last_cache[$key];
|
return $this->_last_cache[$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
|
|
|
@ -55,7 +55,7 @@ if ($ZEROBINCOMPATIBILITY) :
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<?php $this->_scriptTag('js/zlib-1.3.1.js', 'async'); ?>
|
<?php $this->_scriptTag('js/zlib-1.3.1-1.js', 'async'); ?>
|
||||||
<?php $this->_scriptTag('js/base-x-4.0.0.js', 'defer'); ?>
|
<?php $this->_scriptTag('js/base-x-4.0.0.js', 'defer'); ?>
|
||||||
<?php $this->_scriptTag('js/rawinflate-0.3.js', 'defer'); ?>
|
<?php $this->_scriptTag('js/rawinflate-0.3.js', 'defer'); ?>
|
||||||
<?php $this->_scriptTag('js/bootstrap-3.4.1.js', 'defer'); ?>
|
<?php $this->_scriptTag('js/bootstrap-3.4.1.js', 'defer'); ?>
|
||||||
|
|
|
@ -38,7 +38,7 @@ if ($ZEROBINCOMPATIBILITY) :
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<?php $this->_scriptTag('js/zlib-1.3.1.js', 'defer'); ?>
|
<?php $this->_scriptTag('js/zlib-1.3.1-1.js', 'defer'); ?>
|
||||||
<?php $this->_scriptTag('js/base-x-4.0.0.js', 'defer'); ?>
|
<?php $this->_scriptTag('js/base-x-4.0.0.js', 'defer'); ?>
|
||||||
<?php $this->_scriptTag('js/rawinflate-0.3.js', 'defer'); ?>
|
<?php $this->_scriptTag('js/rawinflate-0.3.js', 'defer'); ?>
|
||||||
<?php $this->_scriptTag('js/bootstrap-5.3.3.js', 'async'); ?>
|
<?php $this->_scriptTag('js/bootstrap-5.3.3.js', 'async'); ?>
|
||||||
|
|
|
@ -34,7 +34,7 @@ if ($ZEROBINCOMPATIBILITY):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<?php $this->_scriptTag('js/zlib-1.3.1.js', 'async'); ?>
|
<?php $this->_scriptTag('js/zlib-1.3.1-1.js', 'async'); ?>
|
||||||
<?php $this->_scriptTag('js/base-x-4.0.0.js', 'async'); ?>
|
<?php $this->_scriptTag('js/base-x-4.0.0.js', 'async'); ?>
|
||||||
<?php $this->_scriptTag('js/rawinflate-0.3.js', 'async'); ?>
|
<?php $this->_scriptTag('js/rawinflate-0.3.js', 'async'); ?>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -178,4 +178,18 @@ class FilesystemTest extends TestCase
|
||||||
$this->assertEquals($this->_model->readComments($dataid), array($comment['meta']['created'] => $comment), "comment of $dataid wasn't modified in the conversion");
|
$this->assertEquals($this->_model->readComments($dataid), array($comment['meta']['created'] => $comment), "comment of $dataid wasn't modified in the conversion");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testValueFileErrorHandling()
|
||||||
|
{
|
||||||
|
define('VALID', 'valid content');
|
||||||
|
foreach (array('purge_limiter', 'salt', 'traffic_limiter') as $namespace) {
|
||||||
|
file_put_contents($this->_invalidPath . DIRECTORY_SEPARATOR . $namespace . '.php', 'invalid content');
|
||||||
|
$model = new Filesystem(array('dir' => $this->_invalidPath));
|
||||||
|
ob_start(); // hide "invalid content", when file gets included
|
||||||
|
$this->assertEquals($model->getValue($namespace), '', 'empty default value returned, invalid content ignored');
|
||||||
|
ob_end_clean();
|
||||||
|
$this->assertTrue($model->setValue(VALID, $namespace), 'setting valid value');
|
||||||
|
$this->assertEquals($model->getValue($namespace), VALID, 'valid value returned');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue