mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-12-29 13:15:44 +01:00
preserve configured SRI hashes
This commit is contained in:
parent
5ef8a094e7
commit
2b76898546
2 changed files with 9 additions and 0 deletions
|
@ -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 a new issue