Skip to content

Conversation

@funnywwh
Copy link
Owner

@funnywwh funnywwh commented Nov 14, 2025

…afe prefix checks


Note

Adds a 50 MiB SMTP DATA limit with safer failure logging and introduces stable UID hashing in IMAP while stubbing/simplifying many IMAP/SMTP handlers.

  • SMTP:
    • Enforces 50 MiB limit in Session.Data using io.LimitReader; returns 552 when exceeded.
    • On parse failure, logs hex preview of raw bytes for diagnostics.
    • Simplifies Rcpt to validate recipients by domain only.
    • Removes email rebuild/generation helpers and logout, leaving a leaner flow; retains Reset.
  • IMAP:
    • Adds stableUIDFromID (FNV-1a) for stable uint32 UIDs from string IDs.
    • Streamlines Login and User struct; large mailbox operations (ListMailboxes, GetMailbox, etc.) replaced with stubs.

Written by Cursor Bugbot for commit fefd312. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

return fmt.Errorf("无效的邮箱地址: %s", to)
}
domain := parts[1]
parts := strings.Split(to, "@")[1]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unvalidated Email Split Causes Crash

The code directly accesses strings.Split(to, "@")[1] without checking if the email address contains an @ symbol. If to doesn't contain @, the split returns a slice with only one element, causing an index out of bounds panic when accessing [1].

Fix in Cursor Fix in Web

// 如果解析失败,可能是缺少邮件头,需要重新构建
logger.Warn().Err(err).Msg("邮件解析失败,尝试重新构建邮件头")
previewLen := 1024
logger.Warn().Err(err).Hex("preview", rawData[:previewLen]).Msg("邮件解析失败,尝试重新构建邮件头")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Preview logic panics with small data.

The code slices rawData[:previewLen] where previewLen is 1024, but doesn't check if len(rawData) is at least 1024 bytes. This causes a slice bounds out of range panic when the email data is smaller than 1024 bytes.

Fix in Cursor Fix in Web

@funnywwh funnywwh closed this Nov 14, 2025
@funnywwh funnywwh reopened this Nov 14, 2025
@funnywwh funnywwh closed this Nov 14, 2025
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.

2 participants