Skip to content

fix(search): require .mao suffix in isValidMao to reduce search API c…#6415

Merged
crossle merged 1 commit into
masterfrom
fix/search-mao-validate-domain
May 28, 2026
Merged

fix(search): require .mao suffix in isValidMao to reduce search API c…#6415
crossle merged 1 commit into
masterfrom
fix/search-mao-validate-domain

Conversation

@SeniorZhai
Copy link
Copy Markdown
Member

…alls

The previous regex only excluded whitespace and uppercase, so almost any typed keyword (e.g. 'hello', 'abc', 'a') triggered the MAO user lookup API and risked rate limiting / bans. Tighten isValidMao to match the MAO domain pattern (^[^\sA-Z]{1,128}.mao$) and reject pure-digit names, so the API is only hit when the keyword actually looks like a MAO domain.

…alls

The previous regex only excluded whitespace and uppercase, so almost any
typed keyword (e.g. 'hello', 'abc', 'a') triggered the MAO user lookup API
and risked rate limiting / bans. Tighten isValidMao to match the MAO domain
pattern (^[^\sA-Z]{1,128}\.mao$) and reject pure-digit names, so the API
is only hit when the keyword actually looks like a MAO domain.
@SeniorZhai SeniorZhai requested a review from Copilot May 27, 2026 01:40
@SeniorZhai SeniorZhai added the testing Now testing, but you can review label May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Tightens MAO keyword validation to avoid triggering MAO user lookup for arbitrary search terms, reducing unnecessary network calls and potential rate limiting.

Changes:

  • Updates String?.isValidMao() to require a .mao suffix and match ^[^\\sA-Z]{1,128}\\.mao$.
  • Adds an additional guard to reject digit-only MAO names before allowing the MAO lookup path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (text.all { it.isDigit() }) return false
val regex = Regex("^[^\\sA-Z]{1,128}$")
return regex.matches(text)
val text = this.lowercase()
Comment on lines +827 to +828
val regex = Regex("^[^\\sA-Z]{1,128}\\.mao$")
if (!regex.matches(text)) return false
@crossle crossle merged commit aa1f2f8 into master May 28, 2026
3 checks passed
@crossle crossle deleted the fix/search-mao-validate-domain branch May 28, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Now testing, but you can review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants