Repository navigation
fix(smtp): 在 Reset 中清理会话状态 - #373
Open
0clickjacking0 wants to merge 1 commit into
Open
0clickjacking0 wants to merge 1 commit into
0clickjacking0 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
go-smtp在重置连接时会回调Session.Reset(),包括DATA结束后以及收到RSET命令时。PMail 在
Session.From和Session.To中保存当前邮件的发件人和收件人状态,但当前实现是空函数:go-smtp会清理框架自身的fromReceived和recipients状态,但不会清理 PMail 业务层保存的From/To。因此当同一条 SMTP 连接被复用时,下一封邮件可能继承上一封邮件的收件人,导致同连接上的邮件串发。修复
在
Session.Reset()中清理业务层会话状态:测试
新增单元测试覆盖:
Reset()清理已有From/To状态Reset()对空状态和重复调用保持幂等本地验证命令: