Description
The automated spam detection filter in frontend/src/lib/validation/spamDetection.ts and backend/app/core/moderation_terms.py uses overly aggressive regex matching for URL counting and keyword analysis. When developers share legitimate markdown code snippets (e.g. http.ListenAndServe(':8080', nil) or documentation links), posts and comments are falsely blocked as spam.
Steps to Reproduce
- Create a project update post containing a code snippet with 3 HTTP import statements and 2 GitHub repo links.
- Click 'Publish Update'.
- The submission is rejected with 'Spam detected: excessive link count and suspicious keywords'.
Expected Behavior
- Frontend/Backend: Strip Markdown code blocks (
...) and inline code ticks (...) before running spam keyword and link density analysis.
- Backend: Whitelist trusted developer domains (e.g.
github.com, npmjs.com, docs.python.org, stackoverflow.com).
Implementation Hints
Frontend (frontend/src/lib/validation/spamDetection.ts):
export function sanitizeForSpamCheck(content: string): string {
return content
.replace(/```[\s\S]*?```/g, "")
.replace(/`[^`]*`/g, "")
.trim();
}
export function detectSpam(rawContent: string): boolean {
const sanitized = sanitizeForSpamCheck(rawContent);
const links = sanitized.match(/https?:\/\/[^\s]+/gi) || [];
const untrustedLinks = links.filter(link => !isTrustedDeveloperDomain(link));
return untrustedLinks.length > 3;
}
Affected Files
- frontend/src/lib/validation/spamDetection.ts
- backend/app/core/moderation_terms.py
- backend/app/routers/moderation.py
Labels
type:bug, level:intermediate, GSSoC-26
Description
The automated spam detection filter in
frontend/src/lib/validation/spamDetection.tsandbackend/app/core/moderation_terms.pyuses overly aggressive regex matching for URL counting and keyword analysis. When developers share legitimate markdown code snippets (e.g.http.ListenAndServe(':8080', nil)or documentation links), posts and comments are falsely blocked as spam.Steps to Reproduce
Expected Behavior
...) and inline code ticks (...) before running spam keyword and link density analysis.github.com,npmjs.com,docs.python.org,stackoverflow.com).Implementation Hints
Frontend (
frontend/src/lib/validation/spamDetection.ts):Affected Files
Labels
type:bug, level:intermediate, GSSoC-26