diff options
author | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2015-07-30 13:29:06 +0300 |
---|---|---|
committer | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2015-07-30 23:02:16 +0300 |
commit | 182bc17aebe19f49c30f50aacabdb1c9824c6f68 (patch) | |
tree | 009dfd226788a7765acfe2baf77cfa4935f957db /tests/lib/appframework | |
parent | a07254856ce532bfe5c49c1b53247daf88dbdd4a (diff) |
Sanitize class names before registerService/query
Leading backslashes are removed, so a `registerService('\\OC\\Foo')`
can still be resolved with `query('OC\\Foo')`.
Diffstat (limited to 'tests/lib/appframework')
-rw-r--r-- | tests/lib/appframework/utility/SimpleContainerTest.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/lib/appframework/utility/SimpleContainerTest.php b/tests/lib/appframework/utility/SimpleContainerTest.php index 09857808b9f..d544faf273e 100644 --- a/tests/lib/appframework/utility/SimpleContainerTest.php +++ b/tests/lib/appframework/utility/SimpleContainerTest.php @@ -167,6 +167,25 @@ class SimpleContainerTest extends \Test\TestCase { $this->assertEquals('abc', $this->container->query('test1')); } + public function sanitizeNameProvider() { + return [ + ['ABC\\Foo', 'ABC\\Foo'], + ['\\ABC\\Foo', '\\ABC\\Foo'], + ['\\ABC\\Foo', 'ABC\\Foo'], + ['ABC\\Foo', '\\ABC\\Foo'], + ]; + } + + /** + * @dataProvider sanitizeNameProvider + */ + public function testSanitizeName($register, $query) { + $this->container->registerService($register, function() { + return 'abc'; + }); + $this->assertEquals('abc', $this->container->query($query)); + } + /** * @expectedException \OCP\AppFramework\QueryException */ |