mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-10-01 01:26:10 -04:00
preserve configured SRI hashes
This commit is contained in:
parent
5ef8a094e7
commit
2b76898546
@ -210,6 +210,10 @@ class Configuration
|
||||
}
|
||||
// check for missing keys and set defaults if necessary
|
||||
else {
|
||||
// preserve configured SRI hashes
|
||||
if ($section == 'sri' && array_key_exists($section, $config)) {
|
||||
$this->_configuration[$section] = $config[$section];
|
||||
}
|
||||
foreach ($values as $key => $val) {
|
||||
if ($key == 'dir') {
|
||||
$val = PATH . $val;
|
||||
|
@ -120,9 +120,14 @@ class ConfigurationTest extends TestCase
|
||||
unset($options['expire_options']['1week']);
|
||||
unset($options['expire_options']['1year']);
|
||||
unset($options['expire_options']['never']);
|
||||
$valid_sri = $options['sri'][array_key_first($options['sri'])];
|
||||
$options['sri'][array_key_first($options['sri'])] = ''; // empty string should get replaced with default
|
||||
$options['sri']['js/example.js'] = 'some invalid SRI hash';
|
||||
Helper::createIniFile(CONF, $options);
|
||||
$conf = new Configuration;
|
||||
// restore expected results
|
||||
$options['expire']['default'] = '5min';
|
||||
$options['sri'][array_key_first($options['sri'])] = $valid_sri;
|
||||
$this->assertEquals($options, $conf->get(), 'not overriding "missing" subkeys');
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user