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

ian.packer
18.37.2016 04c70716160fb35f27c62281bc9fe4ead2ccab44
OPENDJ-3032 Fix throwIfIA5IllegalCharacter to check the whole string
2 files modified
14 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java 8 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java 6 ●●●● patch | view | raw | blame | history
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
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 }
        };
    }