-
Notifications
You must be signed in to change notification settings - Fork 109
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
Maintain an internal copy of net/textproto with few fixes for email header #283
Conversation
New functions: readEmailMIMEHeader, CanonicalEmailMIMEHeaderKey, validEmailHeaderFieldByte, canonicalEmailMIMEHeaderKey.
Out of curiosity, is there an issue that was opened in the golang repo related to this? |
I reported this issue in upstream too: golang/go#58862 If you search "net/mail" in golang repo issue tracker, there're many issues similar to this one, all caused due to |
Few questions before I start reviewing:
|
Latest development edition on github.com/golang/go. I can use v1.20.1 if you prefer.
Will move soon.
The fastest way. |
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.
Overall looks good, just one possible change request.
header.go
Outdated
// | ||
// > A field name MUST be composed of printable US-ASCII characters (i.e., | ||
// > characters that have values between 33 and 126, inclusive), except | ||
// > colon. | ||
func validHeaderFieldByte(c byte) bool { |
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.
should we eliminate this func and just call the new one you defined in internal/textproto?
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.
Will do. It was left there on purpose because we may need to remove internal/textproto
someday if upstream fixes it.
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.
Yes, I had similar thought, but we probably will not switch back to upstream quickly.
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.
Would you like to save a patch file in enmime git repo to clearly indicate the changes compared to net/textproto
? It might be easier for us to sync internal/textproto
with upstream but still maintain our own version for email.
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.
Sounds good to me.
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.
@jhillyerd Removed duplicate validHeaderFieldByte.
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.
@jhillyerd Could you help review again? also #284
Use CanonicalEmailMIMEHeaderKey instead of CanonicalMIMEHeaderKey in MIMEHeader methods.
hi @jhillyerd, GitHub Actions failed due to we copied Question: would you like to update |
As a library, I prefer to maintain backwards compatibility. Probably go 1.18 & 1.19 is enough, 1.16.x is pretty old so you could drop that. Thank you. |
GitHub Actions are pending for your action. |
Replaced
@jhillyerd Please help approve the GitHub Actions. |
Obviously we want the Build and Test runs to pass, but don't worry about the Lint, that can be addressed later. |
It's better to allow GitHub Actions when repo receives a new PR or PR gets updated, so that no need to wait for your approval to start the tests. It slows down the contribution process. |
They should auto run now, given this repo doesn't have any deploy keys it should be safe. |
hi @jhillyerd There's a change i'd like to discuss with you first before i modify the code.
I removed the code for such convert in our internal Question for you:
Of course we can tag a new version first with option 1 implemented first, then release a new version with option 2 implemented as a breaking change. Let me know your opinions and final decision. |
For this release, I'd like to prioritize backwards compatibility, to give a smooth upgrade path to Go 1.20 for users. I am wondering if we would be better off just copying in Go 1.19's textproto package, instead of 1.20's? You probably have a better idea of which is worth the effort than me. |
OK.
I will send new commits tonight or tomorrow. Stay tuned and please help review. |
Thanks, hopefully this gets us running on 1.20. I've confirmed that the textproto files being brought in are from go @ 54d05e4e25 with minor changes for backwards compat. |
Big thankyou for your help on this one! |
fixes #282
Introduce internal package
textproto
, it's a clone ofnet/textproto
with few fixes for email header.Changes in new file
textproto/reader_email.go
:ReadEmailMIMEHeader()
andreadEmailMIMEHeader()
.CanonicalEmailMIMEHeaderKey()
andcanonicalEmailMIMEHeaderKey()
ValidEmailHeaderFieldByte()
.validHeaderFieldByte()
validates characters for http header field instead of email header field.One change in
textproto/header.go
:MIMEHeader
methods callCanonicalEmailMIMEHeaderKey
instead ofCanonicalMIMEHeaderKey
.