diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-01-20 23:01:21 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-01-20 23:01:46 +0100 |
commit | 91ed70f0942640bec10bc69a414525a8d1779f8a (patch) | |
tree | a60cfca25c6ca820ab142b5b4199730c6f2f9f32 /apps/user_ldap/lib | |
parent | 9ca4065ef5ccce3a4bc807e4b7bfddd76f50724c (diff) | |
download | nextcloud-server-91ed70f0942640bec10bc69a414525a8d1779f8a.tar.gz nextcloud-server-91ed70f0942640bec10bc69a414525a8d1779f8a.zip |
fix deletion for configIDs < s10
Also move ensureConfigIDExists checks into try, it might throw DB
related exceptions
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Controller/ConfigAPIController.php | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/apps/user_ldap/lib/Controller/ConfigAPIController.php b/apps/user_ldap/lib/Controller/ConfigAPIController.php index 7a5a5c5b7ba..7d51b0aafe4 100644 --- a/apps/user_ldap/lib/Controller/ConfigAPIController.php +++ b/apps/user_ldap/lib/Controller/ConfigAPIController.php @@ -145,12 +145,6 @@ class ConfigAPIController extends OCSController { * @throws OCSException */ public function delete($configID) { - $initial = substr($configID, 0, 1); - $number = substr($configID, 1); - if($initial !== 's' || $number !== strval(intval($number))) { - throw new OCSBadRequestException('Not a valid config ID'); - } - try { $this->ensureConfigIDExists($configID); if(!$this->ldapHelper->deleteServerConfiguration($configID)) { @@ -190,13 +184,13 @@ class ConfigAPIController extends OCSController { * @throws OCSException */ public function modify($configID, $configData) { - $this->ensureConfigIDExists($configID); + try { + $this->ensureConfigIDExists($configID); - if(!is_array($configData)) { - throw new OCSBadRequestException('configData is not properly set'); - } + if(!is_array($configData)) { + throw new OCSBadRequestException('configData is not properly set'); + } - try { $configuration = new Configuration($configID); $configKeys = $configuration->getConfigTranslationArray(); @@ -207,6 +201,8 @@ class ConfigAPIController extends OCSController { } $configuration->saveConfiguration(); + } catch(OCSException $e) { + throw $e; } catch (\Exception $e) { $this->logger->logException($e); throw new OCSException('An issue occurred when modifying the config.'); @@ -287,9 +283,9 @@ class ConfigAPIController extends OCSController { * @throws OCSException */ public function show($configID, $showPassword = false) { - $this->ensureConfigIDExists($configID); - try { + $this->ensureConfigIDExists($configID); + $config = new Configuration($configID); $data = $config->getConfiguration(); if(!boolval(intval($showPassword))) { @@ -301,6 +297,8 @@ class ConfigAPIController extends OCSController { $data[$key] = $value; } } + } catch(OCSException $e) { + throw $e; } catch (\Exception $e) { $this->logger->logException($e); throw new OCSException('An issue occurred when modifying the config.'); @@ -317,7 +315,7 @@ class ConfigAPIController extends OCSController { */ private function ensureConfigIDExists($configID) { $prefixes = $this->ldapHelper->getServerConfigurationPrefixes(); - if(!in_array($configID, $prefixes)) { + if(!in_array($configID, $prefixes, true)) { throw new OCSNotFoundException('Config ID not found'); } } |