# UNDF: UNDF-2026-000000067 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/v1/core/statements/api/IdentifierManagerApi.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/v1/core/statements/api/IdentifierManagerApi.kt @@ -35,6 +35,10 @@ abstract class IdentifierManagerApi { /** All keywords for the database, including [ANSI_SQL_2003_KEYWORDS] and database-specific keywords. */ val keywords by lazy { ANSI_SQL_2003_KEYWORDS + VENDORS_KEYWORDS[currentDialect.name].orEmpty() + dbKeywords() } + // CWE-407 fix: pre-built lowercase HashSet for O(1) case-insensitive keyword lookup + private val keywordsLower: Set by lazy { + keywords.mapTo(HashSet()) { it.lowercase() } + } + /** The database-specific special characters that can be additionally used in unquoted identifiers. */ protected abstract val extraNameCharacters: String @@ -68,7 +73,7 @@ abstract class IdentifierManagerApi { private fun String.isAKeyword(): Boolean = checkedKeywordsCache.getOrPut(lowercase()) { - keywords.any { this.equals(it, true) } + this.lowercase() in keywordsLower }