diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index 8c6c75754..da586a85d 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -251,7 +251,7 @@ $rules = $collection->getAttribute('rules', []);
- +
@@ -404,7 +404,7 @@ $rules = $collection->getAttribute('rules', []);
- +
diff --git a/src/Appwrite/Database/Validator/Key.php b/src/Appwrite/Database/Validator/Key.php index aef689fe0..f6cc7ce91 100644 --- a/src/Appwrite/Database/Validator/Key.php +++ b/src/Appwrite/Database/Validator/Key.php @@ -34,11 +34,15 @@ class Key extends Validator */ public function isValid($value) { + if(!is_string($value)) { + return false; + } + if (preg_match('/[^A-Za-z0-9\-\_]/', $value)) { return false; } - if (mb_strlen($value) > 40) { + if (mb_strlen($value) > 32) { return false; } diff --git a/tests/unit/Database/Validator/KeyTest.php b/tests/unit/Database/Validator/KeyTest.php new file mode 100644 index 000000000..1ec815ce2 --- /dev/null +++ b/tests/unit/Database/Validator/KeyTest.php @@ -0,0 +1,36 @@ +object = new Key(); + } + + public function tearDown() + { + } + + public function testValues() + { + $this->assertEquals($this->object->isValid('dasda asdasd'), false); + $this->assertEquals($this->object->isValid('asdasdasdas'), true); + $this->assertEquals($this->object->isValid('as$$5dasdasdas'), false); + $this->assertEquals($this->object->isValid(false), false); + $this->assertEquals($this->object->isValid(null), false); + $this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscribers'), false); + $this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscriber'), false); + $this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscribe'), true); + $this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscrib'), true); + } +} \ No newline at end of file