From 04c70716160fb35f27c62281bc9fe4ead2ccab44 Mon Sep 17 00:00:00 2001
From: ian.packer <ian.packer@forgerock.com>
Date: Thu, 19 May 2016 09:33:25 +0000
Subject: [PATCH] OPENDJ-3032 Fix throwIfIA5IllegalCharacter to check the whole string
---
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java | 6 +++++-
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java | 8 ++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
index 30fa0ba..1b8bb4a 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
@@ -12,7 +12,7 @@
* information: "Portions Copyright [year] [name of copyright owner]".
*
* Copyright 2009 Sun Microsystems, Inc.
- * Portions copyright 2011-2015 ForgeRock AS.
+ * Portions copyright 2011-2016 ForgeRock AS.
*/
package org.forgerock.opendj.ldap.schema;
@@ -741,9 +741,9 @@
}
private static void throwIfIA5IllegalCharacter(StringBuilder buffer, ByteSequence value) throws DecodeException {
- // Replace any consecutive spaces with a single space and watch out
- // for non-ASCII characters.
- for (int pos = buffer.length() - 1; pos > 0; pos--) {
+ // Check the string for any non-IA5 characters
+ final int bufferLength = buffer.length();
+ for (int pos = 0; pos < bufferLength; pos++) {
final char c = buffer.charAt(pos);
if ((c & 0x7F) != c) {
// This is not a valid character for an IA5 string. If strict
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
index 217222b..6bf8d88 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
@@ -12,7 +12,7 @@
* information: "Portions Copyright [year] [name of copyright owner]".
*
* Copyright 2009 Sun Microsystems, Inc.
- * Portions copyright 2011-2015 ForgeRock AS.
+ * Portions copyright 2011-2016 ForgeRock AS.
*/
package org.forgerock.opendj.ldap.schema;
@@ -84,15 +84,19 @@
@DataProvider
public Object[][] nonAsciiStringProvider() throws Exception {
final String nonAsciiChars = "ëéèêœ";
+ final String singleNonAsciiChar = "ë";
final String nonAsciiCharsReplacement = new String(
new byte[] { b(0x65), b(0xcc), b(0x88), b(0x65), b(0xcc),
b(0x81), b(0x65), b(0xcc), b(0x80), b(0x65), b(0xcc),
b(0x82), b(0xc5), b(0x93), }, "UTF8");
+ final String singleNonAsciiCharReplacement = new String(
+ new byte[] { b(0x65), b(0xcc), b(0x88) }, "UTF8");
return new Object[][] {
{ nonAsciiChars, false, false, nonAsciiCharsReplacement },
{ nonAsciiChars, false, true, nonAsciiCharsReplacement },
{ nonAsciiChars, true, false, nonAsciiCharsReplacement },
{ nonAsciiChars, true, true, nonAsciiCharsReplacement },
+ { singleNonAsciiChar, true, true, singleNonAsciiCharReplacement }
};
}
--
Gitblit v1.10.0