Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/isLikelyEmail-no-control-char.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@objectstack/plugin-auth": patch
---

fix(auth): spell isLikelyEmail's ASCII guard with printable bounds (no control char)

The non-ASCII guard added in framework#3566 was written as `[^\x00-\x7f]`, whose
regex literal embeds a control character (`\x00`). Rewrite it as `[^\x20-\x7e]` —
identical behaviour (anything outside printable ASCII fails the email
pre-filter), but the pattern no longer carries a control character (eslint
`no-control-regex`), and it matches the objectui side's `isPlausibleEmail`.
14 changes: 8 additions & 6 deletions packages/plugins/plugin-auth/src/admin-user-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ function badRequest(message: string): EndpointResult {
*/
export function isLikelyEmail(value: string): boolean {
if (value.length === 0 || value.length > 254 || /\s/.test(value)) return false;
// Reject non-ASCII up front so obviously-invalid addresses (e.g. a Chinese
// domain like `x@柴仟.com`) fail this pre-filter — and therefore the import
// dry-run — instead of passing here only to be rejected later by
// better-auth's strict ASCII validator at real-import time (framework#3566).
// A single linear char-class test; no backtracking (see the ReDoS note above).
if (/[^\x00-\x7f]/.test(value)) return false;
// Reject anything outside printable ASCII up front so obviously-invalid
// addresses (e.g. a Chinese domain like `x@柴仟.com`) fail this pre-filter —
// and therefore the import dry-run — instead of passing here only to be
// rejected later by better-auth's strict ASCII validator at real-import time
// (framework#3566). A single linear char-class test; no backtracking (see the
// ReDoS note above). The range is spelled with printable bounds (0x20–0x7e)
// so the pattern itself carries no control character (eslint no-control-regex).
if (/[^\x20-\x7e]/.test(value)) return false;
const at = value.indexOf('@');
if (at <= 0 || at !== value.lastIndexOf('@') || at === value.length - 1) return false;
const domain = value.slice(at + 1);
Expand Down
Loading