summaryrefslogtreecommitdiffstats
path: root/apps/theming/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-08-01 09:37:12 +0200
committerJoas Schilling <coding@schilljs.com>2016-08-01 09:37:12 +0200
commit13c19e5286cf6e5cdb63044bcda264bc7f453595 (patch)
tree899d7d7c713db10b8cba68b275523d9d6a414d26 /apps/theming/lib
parent50c8367041152ddd574ea283f0a9f08c192a646a (diff)
downloadnextcloud-server-13c19e5286cf6e5cdb63044bcda264bc7f453595.tar.gz
nextcloud-server-13c19e5286cf6e5cdb63044bcda264bc7f453595.zip
Validate the input of the theming options
Diffstat (limited to 'apps/theming/lib')
-rw-r--r--apps/theming/lib/Controller/ThemingController.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php
index 55391619f3c..f788261b747 100644
--- a/apps/theming/lib/Controller/ThemingController.php
+++ b/apps/theming/lib/Controller/ThemingController.php
@@ -100,6 +100,50 @@ class ThemingController extends Controller {
* @internal param string $color
*/
public function updateStylesheet($setting, $value) {
+ $value = trim($value);
+ switch ($setting) {
+ case 'name':
+ if (strlen($value) > 250) {
+ return new DataResponse([
+ 'data' => [
+ 'message' => $this->l->t('The given name is too long'),
+ ],
+ 'status' => 'error'
+ ]);
+ }
+ break;
+ case 'url':
+ if (strlen($value) > 500) {
+ return new DataResponse([
+ 'data' => [
+ 'message' => $this->l->t('The given web address is too long'),
+ ],
+ 'status' => 'error'
+ ]);
+ }
+ break;
+ case 'slogan':
+ if (strlen($value) > 500) {
+ return new DataResponse([
+ 'data' => [
+ 'message' => $this->l->t('The given slogan is too long'),
+ ],
+ 'status' => 'error'
+ ]);
+ }
+ break;
+ case 'color':
+ if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
+ return new DataResponse([
+ 'data' => [
+ 'message' => $this->l->t('The given color is invalid'),
+ ],
+ 'status' => 'error'
+ ]);
+ }
+ break;
+ }
+
$this->template->set($setting, $value);
return new DataResponse(
[