fix: normalize email domain case in validateEmailDomain#40046
fix: normalize email domain case in validateEmailDomain#40046sahillllllllll-bit wants to merge 2 commits intoRocketChat:developfrom
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
WalkthroughEmail domain validation now normalizes domains to lowercase: blocked/allowed lists are trimmed and lowercased when stored, and extracted email domains are lowercased before whitelist/blacklist checks and before MX DNS resolution. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/meteor/app/lib/server/lib/validateEmailDomain.js`:
- Around line 46-48: The comparison is still case-sensitive because emailDomain
is lowercased but emailDomainWhiteList entries are only trimmed; update the
logic in validateEmailDomain (or wherever emailDomainWhiteList is constructed)
to normalize allowlist entries to lower-case (and trim) before use, e.g.
map/emailDomainWhiteList = emailDomainWhiteList.map(e => e.trim().toLowerCase())
or perform a case-insensitive comparison when checking emailDomain against
emailDomainWhiteList so values like "GMAIL.com" match "gmail.com".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7e9c6b22-7633-48bd-8f10-dc039bac8cda
📒 Files selected for processing (1)
apps/meteor/app/lib/server/lib/validateEmailDomain.js
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/app/lib/server/lib/validateEmailDomain.js
🧠 Learnings (1)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
🔇 Additional comments (1)
apps/meteor/app/lib/server/lib/validateEmailDomain.js (1)
21-24: Blocked-domain normalization looks correct.Lowercasing blocked domains at ingestion aligns with the lowercased
emailDomaincomparison path and fixes case-mismatch rejects for blacklist checks.
Fixes #40045
Email domain validation currently treats domains as case-sensitive, which leads to valid email addresses being incorrectly rejected when their casing differs from the configured allowed or blocked domain lists.
For example, an email like
test@GMAIL.comis rejected whengmail.comis present in the allowed domains list.Domain names are case-insensitive by standard, so this behavior is incorrect and results in inconsistent validation.
This PR normalizes both the extracted email domain and the configured domain lists to lowercase before performing comparisons, ensuring consistent and standards-compliant validation.
Summary by CodeRabbit