Skip to content

fix: ArrayIndexOutOfBounds on empty strings#101

Open
jorsol wants to merge 1 commit intomainfrom
fix-ArrayIndexOutOfBounds
Open

fix: ArrayIndexOutOfBounds on empty strings#101
jorsol wants to merge 1 commit intomainfrom
fix-ArrayIndexOutOfBounds

Conversation

@jorsol
Copy link
Copy Markdown
Collaborator

@jorsol jorsol commented May 5, 2026

  1. Fix: ArrayIndexOutOfBounds on Empty Mapping

    If the mapping phase (Step 1) or Normalization phase (Step 2) resulted in an empty string (e.g., a string consisting entirely of characters mapped to "nothing"), the code would throw an ArrayIndexOutOfBoundsException. I have added a guard clause to return early if the value length is zero.

  2. Optimization: Normalizer.isNormalized Guard

    To improve throughput and reduce heap churn, I've implemented a "fast-path" check using Normalizer.isNormalized. Normalizer.normalize() always allocates a new buffer/string; this is avoided if the string is already normalized.

  3. Security: SecureCharBuffer Implementation

    To prevent sensitive password data from lingering in the JVM heap, the StringBuilder is replaced with a custom SecureCharBuffer. Unlike StringBuilder, this buffer implements AutoCloseable. It ensures that the internal char[] is overwritten with zeros (\0) upon closing or resizing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant