mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-07-20 13:39:07 -04:00
handle undefined global, fixes #1544
This commit is contained in:
parent
6347b6193e
commit
c08a792f01
3 changed files with 13 additions and 5 deletions
|
@ -5,6 +5,8 @@
|
||||||
* CHANGED: Passing large data structures by reference to reduce memory consumption (#858)
|
* CHANGED: Passing large data structures by reference to reduce memory consumption (#858)
|
||||||
* CHANGED: Removed use of ctype functions and polyfill library for ctype
|
* CHANGED: Removed use of ctype functions and polyfill library for ctype
|
||||||
* CHANGED: Upgrading libraries to: DOMpurify 3.2.5, ip-lib 1.20.0
|
* CHANGED: Upgrading libraries to: DOMpurify 3.2.5, ip-lib 1.20.0
|
||||||
|
* 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)
|
||||||
|
|
|
@ -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 '';
|
||||||
|
|
|
@ -185,7 +185,9 @@ class FilesystemTest extends TestCase
|
||||||
foreach (array('purge_limiter', 'salt', 'traffic_limiter') as $namespace) {
|
foreach (array('purge_limiter', 'salt', 'traffic_limiter') as $namespace) {
|
||||||
file_put_contents($this->_invalidPath . DIRECTORY_SEPARATOR . $namespace . '.php', 'invalid content');
|
file_put_contents($this->_invalidPath . DIRECTORY_SEPARATOR . $namespace . '.php', 'invalid content');
|
||||||
$model = new Filesystem(array('dir' => $this->_invalidPath));
|
$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');
|
$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->assertTrue($model->setValue(VALID, $namespace), 'setting valid value');
|
||||||
$this->assertEquals($model->getValue($namespace), VALID, 'valid value returned');
|
$this->assertEquals($model->getValue($namespace), VALID, 'valid value returned');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue