From db80ab0ec2570548315d04aad20d324e1c8c54ad Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 03 Feb 2011 11:49:44 +0000
Subject: [PATCH] Fix OPENDJ-27 : schema parsing fails with extensions on syntaxes.
---
opendj-sdk/opends/src/server/org/opends/server/schema/DITStructureRuleSyntax.java | 65 +++++++++++++++++++++++++-------
1 files changed, 50 insertions(+), 15 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/schema/DITStructureRuleSyntax.java b/opendj-sdk/opends/src/server/org/opends/server/schema/DITStructureRuleSyntax.java
index b3adfc3..38e23ec 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/schema/DITStructureRuleSyntax.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/schema/DITStructureRuleSyntax.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
+ * Portions Copyright 2011 ForgeRock AS
*/
package org.opends.server.schema;
import org.opends.messages.Message;
@@ -1086,15 +1087,16 @@
{
// Skip over any leading spaces.
int length = valueStr.length();
- char c = valueStr.charAt(startPos++);
- while ((startPos < length) && (c == ' '))
+ char c = '\u0000';
+ while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
{
- c = valueStr.charAt(startPos++);
+ startPos++;
}
if (startPos >= length)
{
- Message message = ERR_ATTR_SYNTAX_DSR_TRUNCATED_VALUE.get(valueStr);
+ Message message =
+ ERR_ATTR_SYNTAX_DSR_TRUNCATED_VALUE.get(valueStr);
throw new DirectoryException(
ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
@@ -1108,16 +1110,19 @@
{
// Parse until the closing quote.
StringBuilder valueBuffer = new StringBuilder();
- while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != '\''))
+ startPos++;
+ while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\''))
{
valueBuffer.append(c);
+ startPos++;
}
-
+ startPos++;
valueList.add(valueBuffer.toString());
}
else if (c == '(')
{
startPos++;
+ // We're expecting a list of values. Quoted, space separated.
while (true)
{
// Skip over any leading spaces;
@@ -1128,12 +1133,12 @@
if (startPos >= length)
{
- Message message = ERR_ATTR_SYNTAX_DSR_TRUNCATED_VALUE.get(valueStr);
+ Message message =
+ ERR_ATTR_SYNTAX_DSR_TRUNCATED_VALUE.get(valueStr);
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
-
if (c == ')')
{
// This is the end of the list.
@@ -1149,10 +1154,41 @@
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
+ else if (c == '\'')
+ {
+ // We have a quoted string
+ StringBuilder valueBuffer = new StringBuilder();
+ startPos++;
+ while ((startPos < length) &&
+ ((c = valueStr.charAt(startPos)) != '\''))
+ {
+ valueBuffer.append(c);
+ startPos++;
+ }
+
+ valueList.add(valueBuffer.toString());
+ startPos++;
+ }
else
{
- // We'll recursively call this method to deal with this.
- startPos = readExtraParameterValues(valueStr, valueList, startPos);
+ //Consider unquoted string
+ StringBuilder valueBuffer = new StringBuilder();
+ while ((startPos < length) &&
+ ((c = valueStr.charAt(startPos)) != ' '))
+ {
+ valueBuffer.append(c);
+ startPos++;
+ }
+
+ valueList.add(valueBuffer.toString());
+ }
+
+ if (startPos >= length)
+ {
+ Message message =
+ ERR_ATTR_SYNTAX_DSR_TRUNCATED_VALUE.get(valueStr);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
}
}
}
@@ -1160,16 +1196,15 @@
{
// Parse until the next space.
StringBuilder valueBuffer = new StringBuilder();
- while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' '))
+ while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' '))
{
valueBuffer.append(c);
+ startPos++;
}
valueList.add(valueBuffer.toString());
}
-
-
// Skip over any trailing spaces.
while ((startPos < length) && (valueStr.charAt(startPos) == ' '))
{
@@ -1178,12 +1213,12 @@
if (startPos >= length)
{
- Message message = ERR_ATTR_SYNTAX_DSR_TRUNCATED_VALUE.get(valueStr);
+ Message message =
+ ERR_ATTR_SYNTAX_DSR_TRUNCATED_VALUE.get(valueStr);
throw new DirectoryException(
ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
-
return startPos;
}
--
Gitblit v1.10.0