From ff10d91cb881c3c0d5529491cf160044496b5e87 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.
---
opends/src/server/org/opends/server/schema/NameFormSyntax.java | 68 +++++++++++++++++++++++++--------
1 files changed, 51 insertions(+), 17 deletions(-)
diff --git a/opends/src/server/org/opends/server/schema/NameFormSyntax.java b/opends/src/server/org/opends/server/schema/NameFormSyntax.java
index a75176e..8095168 100644
--- a/opends/src/server/org/opends/server/schema/NameFormSyntax.java
+++ b/opends/src/server/org/opends/server/schema/NameFormSyntax.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;
@@ -1142,20 +1143,21 @@
* the value.
*/
private static int readExtraParameterValues(String valueStr,
- List<String> valueList, int startPos)
+ List<String> valueList, int startPos)
throws DirectoryException
{
// 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_NAME_FORM_TRUNCATED_VALUE.get(valueStr);
+ Message message =
+ ERR_ATTR_SYNTAX_NAME_FORM_TRUNCATED_VALUE.get(valueStr);
throw new DirectoryException(
ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
@@ -1169,16 +1171,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;
@@ -1195,7 +1200,6 @@
message);
}
-
if (c == ')')
{
// This is the end of the list.
@@ -1206,14 +1210,46 @@
{
// This is an illegal character.
Message message =
- ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR.get(valueStr, c, startPos);
+ ERR_ATTR_SYNTAX_NAME_FORM_ILLEGAL_CHAR.get(
+ valueStr, c, startPos);
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_NAME_FORM_TRUNCATED_VALUE.get(valueStr);
+ throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
+ message);
}
}
}
@@ -1221,16 +1257,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) == ' '))
{
@@ -1239,17 +1274,16 @@
if (startPos >= length)
{
- Message message = ERR_ATTR_SYNTAX_NAME_FORM_TRUNCATED_VALUE.get(valueStr);
+ Message message =
+ ERR_ATTR_SYNTAX_NAME_FORM_TRUNCATED_VALUE.get(valueStr);
throw new DirectoryException(
ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
}
-
return startPos;
}
-
/**
* {@inheritDoc}
*/
--
Gitblit v1.10.0