Skip to content

Prevent EncryptThis failures on blank tokens - #96

Closed
krotname wants to merge 1 commit into
mainfrom
codex/fix-encryptthis-input-leak-and-crash
Closed

Prevent EncryptThis failures on blank tokens#96
krotname wants to merge 1 commit into
mainfrom
codex/fix-encryptthis-input-leak-and-crash

Conversation

@krotname

@krotname krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The encryptThis helper could throw StringIndexOutOfBoundsException on whitespace-only input or when consecutive whitespace produced empty tokens, so make the function robust to such inputs.
  • Tokenization should treat runs of whitespace as a single separator to preserve expected behavior for inputs with mixed or repeated whitespace.

Description

  • Return early for blank inputs by changing the guard to if (text == null || text.isBlank()) return ""; in src/main/java/kyu6/EncryptThis.java.
  • Change tokenization to split on runs of whitespace by using text.trim().split("\s+") to avoid empty tokens.
  • Add regression tests in src/test/java/kyu6/EncryptThisTest.java that assert correct behavior for consecutive/mixed whitespace and that blank input returns an empty string.

Testing

  • Ran the targeted test with mvn -q -Dtest=EncryptThisTest test, which passed.
  • Ran the full suite with mvn -q test, which passed.
  • Verified no diff check issues with git diff --check (no failures reported).

Codex Task

@krotname

krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the validated combined merge in #115: #115

@krotname krotname closed this Aug 1, 2026
@krotname
krotname deleted the codex/fix-encryptthis-input-leak-and-crash branch August 1, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant