Skip to content

Implement obscenity filter for lobby names and user names - #38

Draft
mterczynski with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-3d39683f-48db-4289-b636-b6f369b3b764
Draft

mterczynski with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-3d39683f-48db-4289-b636-b6f369b3b764

Conversation

Copilot AI commented Aug 28, 2025

Copy link
Copy Markdown
Contributor

Fixes #29 by implementing comprehensive obscenity filtering for both lobby names and user names using the obscenity library with English dataset validation.

Changes Made

Server-side Implementation

  • Added obscenity filtering utility (server/src/utils/obscenity-filter.ts) with proper API configuration using RegExpMatcher and English dataset
  • Enhanced user registration to validate usernames against profanity in addition to existing format validation
  • Added lobby name support - lobbies now require names instead of being identified only by creator
  • Updated lobby creation API to accept and validate lobby names with obscenity filtering
  • Comprehensive test coverage with 31 passing tests including edge cases for profanity detection

Client-side Implementation

  • Added matching client-side obscenity filter with identical validation rules to server
  • Enhanced CreateLobbyForm to include required lobby name input with real-time validation feedback
  • Updated RegisterUserForm with client-side profanity validation before submission
  • Improved LobbyList UI to display lobby names prominently with creator information

Type System Updates

  • Extended shared types to include lobby names in CreateLobbyDto and LobbySummaryDto
  • Added name field to Lobby interface and related data structures
  • Resolved module dependencies using local type definitions to avoid linking issues

Technical Details

The implementation uses the obscenity library's RegExpMatcher with:

  • English dataset with blacklisted and whitelisted terms
  • Recommended transformers for comprehensive pattern matching
  • Case-insensitive detection of inappropriate content
  • Consistent validation between client and server

Validation Examples

// These will be rejected:
createLobby({ name: "fuck chess", password: "123" })  // ❌ Profanity detected
registerUser({ name: "shit", password: "password" })  // ❌ Profanity detected

// These will be accepted:
createLobby({ name: "Chess Masters", password: "123" })  // ✅ Clean content
registerUser({ name: "player123", password: "password" })  // ✅ Clean content

Testing

All tests pass including:

  • Obscenity filter unit tests with clean and inappropriate content
  • User registration with profanity validation
  • Lobby creation with name requirements and profanity filtering
  • Integration tests ensuring client/server consistency

The implementation provides robust protection against inappropriate content while maintaining a smooth user experience with clear error messaging.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits August 28, 2025 09:24
Co-authored-by: mterczynski <27309340+mterczynski@users.noreply.github.com>
- Add obscenity package dependency to server and client
- Create obscenity filter utilities for both server and client
- Add lobby name field to lobby types and data structures
- Update lobby creation API to require and validate lobby names
- Update user registration to validate for profanity
- Add comprehensive tests for obscenity filtering
- Update client forms to include lobby name input with validation
- Update lobby list to display lobby names instead of creator names

Co-authored-by: mterczynski <27309340+mterczynski@users.noreply.github.com>
- Fix chess-shared module import issues by using local type definitions
- Enhance lobby list UI to show both lobby name and creator name
- Improve lobby list visual hierarchy with better styling
- All tests passing with comprehensive obscenity filtering coverage

Co-authored-by: mterczynski <27309340+mterczynski@users.noreply.github.com>
Copilot AI changed the title [WIP] @mterczynski/chess/issues/29 Implement obscenity filter for lobby names and user names Aug 28, 2025
Copilot AI requested a review from mterczynski August 28, 2025 09:38

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why this new file

return;
}

if (name.length > 50) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Should me moved to /shared for consistency between client and server

spellCheck={false}
autoCorrect="off"
autoCapitalize="off"
maxLength={50}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

As above, should be moved to /shared

@mterczynski mterczynski left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Needs adjustments

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.

Use obscenity filter for lobby name/user name

2 participants