Author: rhauch
Date: 2009-03-23 15:31:51 -0400 (Mon, 23 Mar 2009)
New Revision: 786
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/NameValueFactory.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/NameValueFactoryTest.java
Log:
DNA-334 Should not allow creating a Name from a string with multiple non-escaped colons
Changed regular expression used in the NameValueFactory to create values, allowing only a
single non-escaped colon in the name. Added a test case to verify that this change indeed
was required and has the correct behavior.
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/NameValueFactory.java
===================================================================
---
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/NameValueFactory.java 2009-03-20
18:40:19 UTC (rev 785)
+++
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/basic/NameValueFactory.java 2009-03-23
19:31:51 UTC (rev 786)
@@ -62,8 +62,8 @@
protected static final String FULLY_QUALFIED_NAME_PATTERN_STRING =
"\\{([^}]*)\\}(.*)";
protected static final Pattern FULLY_QUALIFIED_NAME_PATTERN =
Pattern.compile(FULLY_QUALFIED_NAME_PATTERN_STRING);
- // Original pattern: (([^:/]*):)?(.*)
- private static final String PREFIXED_NAME_PATTERN_STRING =
"(([^:/]*):)?(.*)";
+ // Original pattern: (([^:/]*):)?([^:]*)
+ private static final String PREFIXED_NAME_PATTERN_STRING =
"(([^:/]*):)?([^:]*)";
private static final Pattern PREFIXED_NAME_PATTERN =
Pattern.compile(PREFIXED_NAME_PATTERN_STRING);
private static Name BLANK_NAME;
Modified:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/NameValueFactoryTest.java
===================================================================
---
trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/NameValueFactoryTest.java 2009-03-20
18:40:19 UTC (rev 785)
+++
trunk/dna-graph/src/test/java/org/jboss/dna/graph/property/basic/NameValueFactoryTest.java 2009-03-23
19:31:51 UTC (rev 786)
@@ -34,6 +34,7 @@
import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.ValueFactory;
+import org.jboss.dna.graph.property.ValueFormatException;
import org.junit.Before;
import org.junit.Test;
@@ -126,6 +127,12 @@
factory.create("a", "", decoder);
}
+ @Test( expected = ValueFormatException.class )
+ public void shouldNotCreateNameFromStringWithMultipleNonEscapedColons() {
+ // This is a requirement of JCR, per the JCR TCK
+ factory.create("a:b:c");
+ }
+
@Test
public void shouldCreateIteratorOverValuesWhenSuppliedIteratorOfUnknownObjects() {
List<String> values = new ArrayList<String>();
Show replies by date