Skip to content

Commit c41b8d4

Browse files
committed
Merge pull request #146 from phpcr/fix-validate-namespaces
fix namespace validation
2 parents f2f87d2 + 1e61749 commit c41b8d4

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/PHPCR/Util/PathHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static function assertValidAbsolutePath($path, $destination = false, $thr
5959
}
6060
if ($namespacePrefixes) {
6161
$matches = array();
62-
preg_match_all('#/(?P<prefixes>[^:]+):#', $path, $matches);
62+
preg_match_all('#/(?P<prefixes>[^/:]+):#', $path, $matches);
6363
$unknown = array_diff(array_unique($matches['prefixes']), $namespacePrefixes);
6464
if (count($unknown)) {
6565
if (!$throw) {

tests/PHPCR/Tests/Util/PathHelperTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@ public function testAssertInvalidAbsolutePath($path, $destination = false)
3737
PathHelper::assertValidAbsolutePath($path, $destination);
3838
}
3939

40+
/**
41+
* @dataProvider dataproviderValidAbsolutePathsWithNamespaces
42+
*/
43+
public function testAssertAbsolutePathNamespace($path)
44+
{
45+
PathHelper::assertValidAbsolutePath($path, false, true, array('jcr', 'nt'));
46+
}
47+
48+
public function dataproviderValidAbsolutePathsWithNamespaces()
49+
{
50+
return array(
51+
array('/parent/child'),
52+
array('/jcr:localname'),
53+
array('/jcr:localname/test'),
54+
array('/jcr:localname/test/nt:node'),
55+
array('/jcr:localname/test/nt:node/bla'),
56+
array('/'),
57+
array('/jcr:foo_/b-a/0^.txt'),
58+
array('/parent[7]/child'),
59+
array('/jcr:localname[3]/test'),
60+
);
61+
}
62+
4063
/**
4164
* @expectedException \PHPCR\NamespaceException
4265
* @expectedExceptionMessage invalidprefix and other-ns

0 commit comments

Comments
 (0)