mofilo_content_filter 1.0.9
mofilo_content_filter: ^1.0.9 copied to clipboard
Local, rule-based content filtering for Flutter. Blocks offensive language, hate speech, and harmful content with bypass detection.
Mofilo Content Filter #
Local, rule-based content filtering using pattern matching for offensive language, threats, and harmful content. Supports profanity, slurs, hate speech, violence, grooming, and self-harm detection.
Quick Start #
import 'package:mofilo_content_filter/mofilo_content_filter.dart';
void main() {
final result = ContentFilter.check(userInput);
if (result.isBlocked) {
print('โ Blocked: ${result.reason}');
} else {
print('โ Content is allowed');
submitContent(userInput);
}
}
That's it! The filter handles normalization, bypass detection, and Scunthorpe-safe matching automatically.
Features #
- ๐ก๏ธ Harmful Content Detection - Slurs, profanity, threats, grooming, CSAM, self-harm
- ๐ง Scunthorpe-Safe - Correctly allows "grape", "therapist", "cocktail", "arsenal"
- โก No External Dependencies - Pure Dart implementation, no network calls
- ๐ Privacy-Friendly - All processing happens locally
- ๐ฏ Bypass Resistance - Handles leetspeak, spacing, character repetition
- ๐ช Motivational Context - Allows "kill it at work", "attack my goals"
- ๐งช Well-Tested - Comprehensive unit tests with real-world edge cases
Installation #
Add to your pubspec.yaml:
dependencies:
mofilo_content_filter: ^1.0.9
Then run:
dart pub get
Or for Flutter projects:
flutter pub get
Usage Examples #
Basic Validation #
final result = ContentFilter.check('hello world');
print(result.isAllowed); // true
print(result.isBlocked); // false
print(result.reason); // null
What It Blocks #
| Category | Examples |
|---|---|
| Racial slurs | n-word, ch*nk, sp*c, etc. |
| Homophobic slurs | f-word (slur), d*ke, etc. |
| Profanity | f*ck, sh*t, c*nt |
| Violence + Children | "attack children", "hurt kids" |
| Violence + Person | "kill you", "rape her" |
| CSAM terms | pedo, loli, childporn |
| Grooming | "our little secret", "age is just a number" |
| Self-harm | "kill yourself", "kys" |
| Hate symbols | 1488, "heil hitler" |
| Sexual harassment | "send nudes" |
Scunthorpe Problem Handling #
Legitimate words containing bad substrings are correctly allowed:
| Word | Contains | Allowed |
|---|---|---|
| grape | "rape" | โ |
| therapist | "rapist" | โ |
| class | "ass" | โ |
| spicy | "spic" | โ |
| bigger | "nigg" | โ |
| cocktail | "cock" | โ |
| shiitake | "shit" | โ |
| arsenal | "arse" | โ |
| scunthorpe | "cunt" | โ |
Motivational Context #
Context-aware detection allows positive expressions:
- "I am unstoppable"
- "I am unbreakable"
- "Attack my goals"
- "Kill it at work"
- "Crush the competition"
- "What doesn't kill you makes you stronger"
Validation Pipeline #
1. Check famous quotes allowlist โ Allow motivational phrases
2. Check hate codes โ Block 1488, etc.
3. Check dangerous phrases โ Block "kill you" (not "kill")
4. Check Scunthorpe allowlist โ Allow "grape", "therapist"
5. Check hard slurs โ Block profanity/slurs
6. Default โ Allow
Design principle: Only block what we're 100% certain about.
Bypass Resistance #
Handles common evasion techniques:
| Technique | Example | Result |
|---|---|---|
| Leetspeak | f0ck, sh1t | Blocked |
| Spacing | f.u.c.k | Blocked |
| Character repeat | fuuuck | Blocked |
Important: What This Package Does and Does NOT Do #
โ What This Package Does #
- Blocks text containing known harmful patterns (slurs, threats, grooming, etc.)
- Handles common bypass attempts (leetspeak, spacing, repetition)
- Avoids false positives on legitimate words (Scunthorpe problem)
- Allows motivational context ("kill it at work", "crush the competition")
- Works offline with zero external dependencies
โ ๏ธ What This Package Does NOT Do #
- Is NOT AI/ML โ it's deterministic pattern matching
- Is NOT 100% comprehensive โ new bypasses require manual updates
- Is NOT multi-language โ English-focused only
- Does NOT understand context beyond specific allowlisted phrases
- Does NOT detect subtle toxicity โ sarcasm, passive aggression, dog whistles
Why does this matter? #
Pattern matching catches what we're 100% certain is harmful, but sophisticated users can always find new bypasses. This package is a first-pass filter โ it catches the obvious stuff fast and locally.
For production chat/social apps, layer additional moderation:
- Human review for flagged content
- AI-based content moderation APIs for nuanced detection
- Community reporting systems
This package is Layer 1 (local pattern matching) in a multi-layer moderation system.
Result Object #
class ContentFilterResult {
final bool isAllowed; // true if content is safe
final String? reason; // blocking reason (if blocked)
final List<String> violations; // list of violations found
final ContentFilterSeverity severity; // none, low, medium, high, critical
bool get isBlocked => !isAllowed; // convenience getter
}
API Reference #
ContentFilter.check(text) โ ContentFilterResult
Testing #
177 unit tests covering real-world scenarios:
- โ Known slurs and profanity
- โ Scunthorpe-safe words (grape, therapist, cocktail, etc.)
- โ Motivational phrases and famous quotes
- โ Bypass attempts (leetspeak, spacing, repetition)
- โ Edge cases and boundary conditions
Use Cases #
Great for apps that need fast, local content filtering as a first pass:
- Social platforms (first-pass filter before AI moderation)
- Chat applications (block obvious harmful content instantly)
- User-generated content (validate titles, descriptions, usernames)
- Children's apps (block inappropriate language locally)
Contributing #
Found a false positive or bypass? Issues and pull requests are welcome! Please follow the existing code style and include tests for new features.
License & Legal #
MIT License - Copyright (c) 2025 Mofilo
This software is provided "AS IS" without warranty of any kind. The authors are not liable for any damages arising from its use. This package performs pattern-based filtering only and does not guarantee comprehensive content moderation. Users should implement additional verification layers for production use. See LICENSE for full terms.
Built by the Mofilo team