Skip to content

Commit 73ff499

Browse files
committed
Merge pull request #143 from phpcr/binary-path-encoding
Add some tests for encoding issues in binary paths
2 parents fb0faeb + ab7a83e commit 73ff499

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

fixtures/05_Reading/encoding.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,15 @@
5858
<sv:value>nt:unstructured</sv:value>
5959
</sv:property>
6060
</sv:node>
61+
<sv:node sv:name="node?">
62+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
63+
<sv:value>nt:unstructured</sv:value>
64+
</sv:property>
65+
</sv:node>
66+
<sv:node sv:name="node-¢">
67+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
68+
<sv:value>nt:unstructured</sv:value>
69+
</sv:property>
70+
</sv:node>
6171
</sv:node>
6272
</sv:node>

fixtures/general/base.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
<sv:property sv:name="jcr:data" sv:type="Binary">
4444
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
4545
</sv:property>
46+
<sv:property sv:name="encoding?%$-test" sv:type="Binary">
47+
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
48+
</sv:property>
49+
<sv:property sv:name="encoding?" sv:type="Binary">
50+
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
51+
</sv:property>
4652
<sv:property sv:name="multidata" sv:type="Binary" sv:multiple="true">
4753
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
4854
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>

tests/05_Reading/BinaryReadMethodsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,24 @@ public function testGetLengthMultivalue()
116116
$this->assertEquals(strlen($this->decodedstring), $size);
117117
}
118118
}
119+
120+
public function testReadBinaryPathEncoding()
121+
{
122+
$node = $this->session->getRootNode()->getNode('tests_general_base/index.txt/jcr:content');
123+
$binary = $node->getProperty('encoding?%$-test');
124+
$this->assertEquals(\PHPCR\PropertyType::BINARY, $binary->getType());
125+
$value = $binary->getString();
126+
$this->assertInternalType('string', $value);
127+
$this->assertEquals($this->decodedstring, $value);
128+
}
129+
130+
public function testReadBinaryPathTrailingQuestionmark()
131+
{
132+
$node = $this->session->getRootNode()->getNode('tests_general_base/index.txt/jcr:content');
133+
$binary = $node->getProperty('encoding?');
134+
$this->assertEquals(\PHPCR\PropertyType::BINARY, $binary->getType());
135+
$value = $binary->getString();
136+
$this->assertInternalType('string', $value);
137+
$this->assertEquals($this->decodedstring, $value);
138+
}
119139
}

tests/05_Reading/EncodingTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public static function getNodeNames()
4545
array("node- -x"),
4646
array("node-ç-x"),
4747
array("node-&-x"),
48+
array("node?"),
49+
array("node-¢"),
4850
);
4951
}
5052
}

0 commit comments

Comments
 (0)