-
Notifications
You must be signed in to change notification settings - Fork 941
remove duplicate field stripping #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Agree, but it's a breaking API change. We could introduce a new API to instantiate a field with a value only, like The current |
Does this completely remove the need for strip_field? If so, #719 might not be needed if this gets accepted. |
yes, this kills strip_field I never saw anyone use the field api directly, mostly either parsing whole mails or building them via actionmailer, so not sure if that's a real use-case. It's also very easy to change offending code to be |
all green now (at least locally) |
Anything missing here ? |
You'll need to deprecate the API—or introduce new API—rather than making a breaking change. |
lib/mail/envelope.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that strip_field
used to always return a string. Now we may be super
ing with a range of values that we didn't design for (or test).
made all values not sure why we need any new api, this seems to work fine:
also very few people should be using Field directly ... |
does this need more or can it get merged ? |
@jeremy what do I need to do to get this merged ? |
You'll need to deprecate the API—or introduce new API—rather than making a breaking change. |
It's still possible to create a field with a name and value, so no new api needed, right ? |
We could introduce a new API to instantiate a field with a value only, like The current |
If someone needs the split feature they can just to |
and Field without name would just be |
This is also not affecting basic Field usage, only subclasses, so |
ran into this gain when doing outbound email ... would love to get this merged ... I don't see anyone using this api anyway ... |
4ab36b5
to
c0bfa2c
Compare
@jeremy rebased, can we get this merged now ? (using this patch in apps that both handle inbound and outbound mail without any issues since over a year now ... ) |
@grosser You might have to rebase this again |
done! |
c0bfa2c
to
b7de62f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leave this spec in place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels useless to me ... but added it back if that makes you happy ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! It's to prove that this bug is still fixed: https://github.com/mikel/mail/pull/719/files
b7de62f
to
24884b8
Compare
Fixes mail with a legit "Subject: subject: foo" header. We'd split that into a subject field with a "subject: foo" value. When we instantiate the SubjectField and pass that value, we'd strip the leading "subject: " from it again! So we'd end up with a "foo" subject. This fixes the issue at the cost of some obscure backward compatibility. 1. If you instantiate internal header fields directly, bypassing Mail::Field, then using them to parse raw headers will now fail. This will now be treated as a literal value: Mail::ToField.new('To: foo@example.com') # => Mail::Field::IncompleteParseError: Mail::AddressList can not parse |To: foo@example.com|: Only able to parse up to "To: foo@example.com" Instead, use Mail::Field.parse: Mail::Field.parse('To: foo@example.com') # => #<Mail::ToField …> 2. If you parse fields by instantiating Mail::Field.new with a raw header, it'll now warn you with a deprecation error. That behavior will go away in Mail 2.8.0. Mail::Field.new('To: foo@example.com') # => Passing an unparsed header field to Mail::Field.new is deprecated and will be removed in Mail 2.8.0. Use Mail::Field.parse instead. # => #<Mail::Field 0x7fa401026910 @charset="utf-8" @name="To" @value="foo"> Instead, use Mail::Field.parse: Mail::Field.parse('To: foo@example.com') # => #<Mail::ToField …> Thanks to @grosser for #766 ❤️ Closes #1111
since I updated to 2.7.0, I have this issue :
|
@bf4 @jeremy @mikel
calling afield with it's own name seems like a pretty useless feature, removing this breaks ~30 specs, that I'd fix if we decide to go this way ...
#720
Ideally the .to_s would not be necessary, but something in mail or action_mailer passes in a class for content_transfer_encoding :/
fix: