mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Ludovic Poitou
03.49.2011 ff10d91cb881c3c0d5529491cf160044496b5e87
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}
   */