Author: reschke
Date: Fri Jan 26 17:37:48 2018
New Revision: 1822332
URL: http://svn.apache.org/viewvc?rev=1822332&view=rev
Log:
OAK-4857: Support space chars common in CJK inside item names
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/name/Namespaces.java
jackrabbit/oak/trunk/oak-doc/src/site/markdown/constraints.md
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValidNamesTest.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=1822332&r1=1822331&r2=1822332&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
Fri Jan 26 17:37:48 2018
@@ -60,20 +60,27 @@ 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.
+ * By default, item 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");
/**
- * By default node names with control characters are not allowed.
+ * By default, item names with control characters are not allowed.
* Oak releases prior to 1.10 allowed these (in conflict with the JCR
* specification), so if required the check can be turned off.
* See OAK-7208.
*/
private static final boolean allowOtherControlChars =
Boolean.getBoolean("oak.allowOtherControlChars");
+ /**
+ * By default, item names with non-ASCII whitespace characters are allowed.
+ * Oak releases prior to 1.10 disallowed these, so if required the check
can
+ * be turned on again. See OAK-4857.
+ */
+ private static final boolean disallowNonASCIIWhitespaceChars =
Boolean.getBoolean("oak.disallowNonASCIIWhitespaceChars");
+
private Namespaces() {
}
@@ -259,8 +266,18 @@ public class Namespaces implements Names
}
for (int i = 0; i < local.length(); i++) {
+
char ch = local.charAt(i);
- boolean spaceChar = allowOtherWhitespaceChars ?
Character.isSpaceChar(ch) : Character.isWhitespace(ch);
+
+ boolean spaceChar;
+ if (disallowNonASCIIWhitespaceChars) {
+ // behavior before OAK-4857 was fixed
+ spaceChar = allowOtherWhitespaceChars ?
Character.isSpaceChar(ch) : Character.isWhitespace(ch);
+ } else {
+ // disallow just leading and trailing ' ', plus CR, LF and TAB
+ spaceChar = ch == ' ' || ch == 0x9 || ch == 0xa || ch == 0xd;
+ }
+
if (spaceChar) {
if (i == 0) {
return false; // leading whitespace
Modified: jackrabbit/oak/trunk/oak-doc/src/site/markdown/constraints.md
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-doc/src/site/markdown/constraints.md?rev=1822332&r1=1822331&r2=1822332&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-doc/src/site/markdown/constraints.md (original)
+++ jackrabbit/oak/trunk/oak-doc/src/site/markdown/constraints.md Fri Jan 26
17:37:48 2018
@@ -35,7 +35,7 @@ On top of that, Oak implements several *
- The space character (U+0020) is disallowed at the beginning and the end of
a (local) name (see [JCR v2.0 Specification, Section
5.2.2.1](https://docs.adobe.com/content/docs/en/spec/jcr/2.0/5_Reading.html#5.2.2.1%20Name%20Patterns)
for motivation).
-- Other [Whitespace
characters](https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html#isWhitespace-char-)
are disallowed (but see
[OAK-4857](https://issues.apache.org/jira/browse/OAK-4857)).
+- Other ASCII whitespace characters (CR, LF, TAB) are always disallowed
(before OAK 1.10, more were disallowed, see
[OAK-4857](https://issues.apache.org/jira/browse/OAK-4857)).
Finally, the chosen persistence implementation might restrict node names even
further, for instance:
Modified:
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValidNamesTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValidNamesTest.java?rev=1822332&r1=1822331&r2=1822332&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValidNamesTest.java
(original)
+++
jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/ValidNamesTest.java
Fri Jan 26 17:37:48 2018
@@ -289,10 +289,9 @@ public class ValidNamesTest extends Abst
nameTest("foo\u00a0bar");
}
- // OAK-4587
@Test
public void testEnclosedIdeographicSpace() {
- unsupportedNameTest("foo\u3000bar", RepositoryException.class);
+ nameTest("foo\u3000bar");
}
@Test