Skip to content

Honor exception: false for strings with null bytes - #550

Open
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/honor-nul-exception-false
Open

Honor exception: false for strings with null bytes#550
OskarEichler wants to merge 1 commit into
ruby:masterfrom
OskarEichler:codex/honor-nul-exception-false

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary:

  • detect embedded NUL bytes before StringValueCStr in non-raising conversion mode
  • return nil when exception: false
  • retain the existing ArgumentError when exceptions are enabled

Why:
StringValueCStr raises string contains null byte before BigDecimal’s parser can honor exception: false. Core Float and Integer conversions use their non-raising option for this case, and BigDecimal already documents the same conversion mode.

Verification:

  • baseline reproduction raises for BigDecimal("1\0", exception: false)
  • fixed reproduction returns nil; exception: true still raises; ordinary strings are unchanged
  • full current suite: 266 tests, 13,616 assertions, 0 failures/errors/omissions
  • RBS suite: 146 tests, 1,805 assertions, 0 failures/errors

Compatibility:
Only strings invalid because of an embedded NUL change in the explicitly non-raising mode.

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