Repository navigation
[CS-1425] Handle email addresses with spaces in local part - #38
Conversation
- Add support for unquoted spaces (e.g., 'g speel@example.com') that are marked as exceptional but still allow domain extraction - Add support for quoted spaces (e.g., '"g speel"@example.com') that remove quotes in to_s and are marked as exceptional - Bump version to 2.0.6 Co-Authored-By: Grant <grantspeelman@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes handling of email addresses containing spaces in the local part by adding validation to detect when the Mail gem fails to parse the local portion. When an email like g. speel@example.com is provided, the Mail gem silently sets local to nil without raising an error, which this change now catches and converts to an ExceptionalValue.
Changes:
- Added validation in
EmailAddress#initializeto raise ArgumentError when local part is nil for non-blank addresses - Updated cast methods in both
EmailAddressandDisplayNameEmailAddressto rescue ArgumentError and convert to ExceptionalValue - Added comprehensive test coverage for unquoted spaces, period+space combinations, and valid quoted spaces
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/rails_values/email_address.rb | Added nil local part validation and ArgumentError rescue in cast method |
| lib/rails_values/display_name_email_address.rb | Added ArgumentError rescue in cast method for consistency |
| spec/rails_values/email_address_spec.rb | Added test cases for space handling edge cases |
| rails_values.gemspec | Bumped version to 2.0.6 |
| CHANGELOG.md | Documented the email address space handling fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ixes handling of email addresses with a period followed by a space in the local part
(e.g., g. speel@example.com).
The Mail gem silently fails when parsing this specific pattern - it sets local to nil
without raising an error. This change adds validation to detect when the Mail gem can't
determine the local part and properly marks such addresses as exceptional.
What changed:
for non-blank addresses
per RFC 5322)
This ensures the edge case is caught early rather than silently passing through with
incomplete parsing.
Devin session: https://app.devin.ai/sessions/7c98f21a4e8a404c9febed036f9b9820
Requested by: Grant