Skip to content

fix: ArrayIndexOutOfBoundsException on empty string after mapping#101

Merged
jorsol merged 5 commits intomainfrom
fix-ArrayIndexOutOfBounds
May 8, 2026
Merged

fix: ArrayIndexOutOfBoundsException on empty string after mapping#101
jorsol merged 5 commits intomainfrom
fix-ArrayIndexOutOfBounds

Conversation

@jorsol
Copy link
Copy Markdown
Collaborator

@jorsol jorsol commented May 5, 2026

  • fix: ArrayIndexOutOfBoundsException on empty string after 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.
    Now there is a guard clause to return early if the value length is zero.

  • fix: add Normalizer.isNormalized guard to avoid allocations
    Improve throughput and reduce heap churn, use a "fast-path" check using
    Normalizer.isNormalized. Normalizer.normalize() always allocates a new
    buffer/string; this is avoided if the string is already normalized.

  • feat: add SecureStringBuilder for memory-safe string building
    Introduced SecureStringBuilder to handle sensitive data during
    stringprep operations. Unlike standard StringBuilder, this
    implementation ensures internal buffers are zeroed out on resize and
    closure to mitigate memory exposure of cryptographic material.

  • chore: replace individual boolean flags with EnumSet from profile
    Refactored Stringprep to store the EnumSet directly instead of unpacking
    it into 18 individual boolean flags. This eliminates constructor
    boilerplate, reduces class bloat, and simplifies the internal state.

jorsol added 5 commits May 6, 2026 13:56
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.
Now there is a guard clause to return early if the value length is zero.
Improve throughput and reduce heap churn, use a "fast-path" check using
Normalizer.isNormalized. Normalizer.normalize() always allocates a new
buffer/string; this is avoided if the string is already normalized.
Introduced SecureStringBuilder to handle sensitive data during
stringprep operations. Unlike standard StringBuilder, this
implementation ensures internal buffers are zeroed out on resize and
closure to mitigate memory exposure of cryptographic material.
Refactored Stringprep to store the EnumSet directly instead of unpacking
it into 18 individual boolean flags. This eliminates constructor
boilerplate, reduces class bloat, and simplifies the internal state.
@jorsol jorsol force-pushed the fix-ArrayIndexOutOfBounds branch from 6c3c89a to 7c13108 Compare May 8, 2026 09:14
@jorsol jorsol changed the title fix: ArrayIndexOutOfBounds on empty strings fix: ArrayIndexOutOfBoundsException on empty string after mapping May 8, 2026
@jorsol jorsol merged commit da2e0a3 into main May 8, 2026
4 checks passed
@jorsol jorsol deleted the fix-ArrayIndexOutOfBounds branch May 8, 2026 09:20
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