allow empty settings (required for root directory)
This commit is contained in:
parent
10b9ef929b
commit
ad5fb928fa
|
@ -101,7 +101,7 @@ class SettingsService {
|
|||
$settings[$name] = $value = $this->attrs[$name]['validate']($value);
|
||||
}
|
||||
if (!array_key_exists($name, $this->attrs)
|
||||
|| empty($value)
|
||||
|| $value === null
|
||||
|| $value === $this->attrs[$name]['default']
|
||||
) {
|
||||
unset($settings[$name]);
|
||||
|
@ -123,7 +123,7 @@ class SettingsService {
|
|||
// use default for empty settings
|
||||
$toBeSaved = false;
|
||||
foreach ($this->attrs as $name => $attr) {
|
||||
if (!property_exists($settings, $name) || empty($settings->{$name})) {
|
||||
if (!property_exists($settings, $name)) {
|
||||
$defaultValue = $attr['default'];
|
||||
if (is_callable($defaultValue)) {
|
||||
$settings->{$name} = $defaultValue($uid);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
v-model="settings.notesPath"
|
||||
type="text"
|
||||
name="notesPath"
|
||||
:placeholder="t('notes', 'path to notes')"
|
||||
:placeholder="t('notes', 'root directory')"
|
||||
@change="onChangeSettingsReload"
|
||||
><input type="submit" class="icon-confirm" value="">
|
||||
</form>
|
||||
|
|
|
@ -181,6 +181,9 @@ class APIv1Test extends CommonAPITest {
|
|||
], (object)[
|
||||
'notesPath' => 'New-Test-Notes-Folder2',
|
||||
], 'Update notesPath with path traversal check');
|
||||
$this->updateSettings($settings, (object)[
|
||||
'notesPath' => '',
|
||||
], (object)[], 'Update notesPath with root directory');
|
||||
$this->updateSettings($settings, (object)[
|
||||
'fileSuffix' => 'illegal value',
|
||||
], (object)[
|
||||
|
|
Loading…
Reference in New Issue