Skip to content

fix string length validation using char count instead of byte length - #41

Merged
baptiste0928 merged 1 commit into
baptiste0928:mainfrom
ZeldaFan0225:fix/string-length-validation
May 27, 2026
Merged

fix string length validation using char count instead of byte length#41
baptiste0928 merged 1 commit into
baptiste0928:mainfrom
ZeldaFan0225:fix/string-length-validation

Conversation

@ZeldaFan0225

Copy link
Copy Markdown
Contributor

Discord validates string option lengtsh using Unicode character count (same as Python's len()), not byte count. The current impülementation uses value.len() which returns the UTF-8 byte length in Rust, causing false validation failures for strings containing multibyte characters (accented letters, CJK characters, emojis, etc.) that are otherwise within Discord's limit.

This also replaces the todo!() stubs with proper ParseOptionErrorType::StringLengthOutOfRange errors.

@baptiste0928

Copy link
Copy Markdown
Owner

Thanks for the PR!

@baptiste0928
baptiste0928 merged commit 5fbdd8a into baptiste0928:main May 27, 2026
6 checks passed
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.

2 participants