You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2015/09/24 09:06:12 UTC
svn commit: r1705005 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java
Author: chetanm
Date: Thu Sep 24 07:06:12 2015
New Revision: 1705005
URL: http://svn.apache.org/viewvc?rev=1705005&view=rev
Log:
OAK-3412 - Node name having non space whitspace chars should not be allowed
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java?rev=1705005&r1=1705004&r2=1705005&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java Thu Sep 24 07:06:12 2015
@@ -58,6 +58,13 @@ public class Namespaces implements Names
*/
private static final Map<String, String> ENCODED_URIS = newConcurrentMap();
+ /**
+ * By default node names with non space whitespace chars are not allowed.
+ * However initial Oak release did allowed that and this flag is provided
+ * to revert back to old behaviour if required for some case temporarily
+ */
+ private static final boolean allowOtherWhitespaceChars = Boolean.getBoolean("oak.allowOtherWhitespaceChars");
+
private Namespaces() {
}
@@ -244,7 +251,8 @@ public class Namespaces implements Names
for (int i = 0; i < local.length(); i++) {
char ch = local.charAt(i);
- if (Character.isSpaceChar(ch)) {
+ boolean spaceChar = allowOtherWhitespaceChars ? Character.isSpaceChar(ch) : Character.isWhitespace(ch);
+ if (spaceChar) {
if (i == 0) {
return false; // leading whitespace
} else if (i == local.length() - 1) {
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java?rev=1705005&r1=1705004&r2=1705005&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/name/NameValidatorTest.java Thu Sep 24 07:06:12 2015
@@ -89,6 +89,11 @@ public class NameValidatorTest {
validator.childNodeAdded("name", EMPTY_NODE);
}
+ @Test(expected = CommitFailedException.class)
+ public void testNameWithLineBreaks() throws Exception{
+ validator.childNodeAdded("name\tx", EMPTY_NODE);
+ }
+
@Test
public void testDeleted() throws CommitFailedException {
validator.childNodeDeleted(".", EMPTY_NODE);