Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/org/owasp/esapi/EncoderConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public class EncoderConstants {
}

/**
* a-b
* a-z
*/
public final static char[] CHAR_LOWERS = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
public final static Set<Character> LOWERS;
static {
LOWERS = CollectionsUtil.arrayToSet(CHAR_PASSWORD_SPECIALS);
LOWERS = CollectionsUtil.arrayToSet(CHAR_LOWERS);
}

/**
Expand Down Expand Up @@ -81,7 +81,7 @@ public class EncoderConstants {
public final static char[] CHAR_PASSWORD_LOWERS = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
public final static Set<Character> PASSWORD_LOWERS;
static {
PASSWORD_LOWERS = CollectionsUtil.arrayToSet(CHAR_ALPHANUMERICS);
PASSWORD_LOWERS = CollectionsUtil.arrayToSet(CHAR_PASSWORD_LOWERS);
}

/**
Expand Down
54 changes: 54 additions & 0 deletions src/test/java/org/owasp/esapi/EncoderConstantsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* OWASP Enterprise Security API (ESAPI)
*
* This file is part of the Open Web Application Security Project (OWASP)
* Enterprise Security API (ESAPI) project. For details, please see
* <a href="http://www.owasp.org/index.php/ESAPI">http://www.owasp.org/index.php/ESAPI</a>.
*
* Copyright (c) 2026 - The OWASP Foundation
*
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
* LICENSE before you use, modify, and/or redistribute this software.
*/
package org.owasp.esapi;

import static org.junit.Assert.assertEquals;

import java.util.Set;

import org.junit.Test;
import org.owasp.esapi.util.CollectionsUtil;

/**
* Each {@code Set<Character>} in {@link EncoderConstants} should hold exactly
* the characters of its matching {@code CHAR_*} array.
*/
public class EncoderConstantsTest {

private static void assertSameChars(char[] expected, Set<Character> actual) {
assertEquals(CollectionsUtil.arrayToSet(expected), actual);
}

@Test
public void testLowers() {
assertSameChars(EncoderConstants.CHAR_LOWERS, EncoderConstants.LOWERS);
}

@Test
public void testPasswordLowers() {
assertSameChars(EncoderConstants.CHAR_PASSWORD_LOWERS, EncoderConstants.PASSWORD_LOWERS);
}

@Test
public void testOtherSetsMatchTheirArrays() {
assertSameChars(EncoderConstants.CHAR_PASSWORD_SPECIALS, EncoderConstants.PASSWORD_SPECIALS);
assertSameChars(EncoderConstants.CHAR_UPPERS, EncoderConstants.UPPERS);
assertSameChars(EncoderConstants.CHAR_DIGITS, EncoderConstants.DIGITS);
assertSameChars(EncoderConstants.CHAR_SPECIALS, EncoderConstants.SPECIALS);
assertSameChars(EncoderConstants.CHAR_LETTERS, EncoderConstants.LETTERS);
assertSameChars(EncoderConstants.CHAR_ALPHANUMERICS, EncoderConstants.ALPHANUMERICS);
assertSameChars(EncoderConstants.CHAR_PASSWORD_UPPERS, EncoderConstants.PASSWORD_UPPERS);
assertSameChars(EncoderConstants.CHAR_PASSWORD_DIGITS, EncoderConstants.PASSWORD_DIGITS);
assertSameChars(EncoderConstants.CHAR_PASSWORD_LETTERS, EncoderConstants.PASSWORD_LETTERS);
}
}