mofilo_content_filter 1.0.1
mofilo_content_filter: ^1.0.1 copied to clipboard
A comprehensive content filtering package for Flutter that blocks offensive language, hate speech, profanity, and harmful content in multiple languages with advanced bypass detection.
Mofilo Content Filter #
A comprehensive content filtering package for Flutter that blocks offensive language, hate speech, profanity, and harmful content.
⚠️ Important Disclaimers #
This is a first-line defense tool, NOT a complete moderation solution.
- ❌ NOT 100% accurate - No automated filter is perfect
- ❌ NOT a replacement for human moderation - Requires human review as backup
- ❌ NO guarantee of legal compliance - Consult legal counsel for regulations
- ✅ Best used for: Food names, brand names, usernames, product titles
- ⚠️ See DISCLAIMER.md for full legal terms
By using this package, you accept full responsibility for content moderation in your application.
Features #
- Multi-layer Detection: 12+ detection layers to catch sophisticated bypass attempts
- Multi-language Support: Filters offensive content in English, Spanish, French, German, Polish, Russian, Portuguese, Italian, Dutch
- Advanced Normalization: Catches l33tspeak, Unicode tricks, zero-width characters, emojis, and visual lookalikes
- Bypass Prevention: Detects encoding (Base64, ROT13, Hex, reversed text), spacing tricks, and character substitution
- Security Protection: Blocks SQL injection, XSS, and other attack patterns
- Comprehensive Coverage: Filters profanity, slurs, hate speech, violence, sexual content, self-harm, and more
- Fuzzy Matching: Uses Levenshtein distance to catch misspellings and variations
- Fast & Offline: <5ms latency, no external API calls, privacy-friendly
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
mofilo_content_filter: ^1.0.1
Then run:
flutter pub get
Usage #
Quick Start (Recommended) #
import 'package:mofilo_content_filter/mofilo_content_filter.dart';
// Check any text input
final result = ContentFilter.check(userInput);
if (result.isBlocked) {
print('Blocked: ${result.reason}');
// Show error to user
} else {
print('Content is safe!');
// Proceed with submission
}
Validate Food Names #
// Validate a food name
final result = ContentFilter.validateFoodName("chocolate cake");
if (result.isAllowed) {
print("Food name is safe!");
} else {
print("Blocked: ${result.reason}");
print("Violations: ${result.violations}");
print("Severity: ${result.severity}");
}
Validate Multiple Fields #
// Validate food name and brand together
final results = ContentFilter.validateAll(
foodName: "pizza",
brandName: "Pizza Hut",
);
if (results.isEmpty) {
print("All content is safe!");
} else {
results.forEach((field, result) {
print("$field blocked: ${result.reason}");
});
}
Custom Validation #
// Validate with custom fields
final result = ContentFilter.filter(
foodName: "apple pie",
brandName: "Grandma's",
);
if (!result.isAllowed) {
// Handle blocked content
showError(result.reason);
}
What Gets Blocked #
The filter detects and blocks:
Language-Based #
- Profanity and vulgar language (multiple languages)
- Racial, ethnic, and religious slurs
- Homophobic and transphobic slurs
- Sexist and misogynistic language
- Ableist slurs
Threat-Based #
- Violence and death threats
- Terrorism and extremism
- Hate speech and symbols
- Nazi/white supremacy content
- Holocaust denial
Harmful Content #
- Self-harm and suicide encouragement
- Child abuse and pedophilia references (CSAM)
- Sexual content and harassment
- Drug references
- Animal abuse
Technical Attacks #
- SQL injection attempts
- XSS (Cross-Site Scripting)
- Spam and gibberish patterns
- Encoded malicious content (Base64, ROT13, etc.)
Bypass Techniques Defended Against #
- Character Substitution: l33tspeak (f0ck, sh1t), symbols (@ss, f*ck)
- Spacing/Separators: f.u.c.k, f-u-c-k, f u c k
- Unicode Tricks: Cyrillic (фuck), fullwidth (fuck), circled (ⓕⓤⓒⓚ)
- Zero-Width Characters: fuck (invisible chars)
- Emojis: f😀u😀c😀k
- Encoding: Base64, ROT13, Hex, reversed text
- Mixed Case: FuCk, FUCK, fUcK
- Asterisks: fk, ner
- Homoglyphs: Using visually similar characters
- Fuzzy Spelling: fck, fuk, fuuk (Levenshtein distance matching)
Result Object #
class ContentFilterResult {
final bool isAllowed; // Whether content passes filter
final bool isBlocked; // Opposite of isAllowed (convenience)
final String? reason; // Reason for blocking (if blocked)
final List<String> violations; // List of specific violations
final ContentFilterSeverity severity; // Severity level
}
enum ContentFilterSeverity {
none, // Content is safe
low, // Suspicious but might be legitimate
medium, // Likely violation
high, // Definite violation
critical, // Severe violation (slurs, hate speech, CSAM)
}
Best Practices #
✅ DO:
- Use this as your first-line defense
- Implement human moderation as backup
- Allow users to report false positives
- Monitor filter performance in your use case
- Keep the package updated
- Read the DISCLAIMER.md thoroughly
❌ DON'T:
- Rely solely on this filter
- Use for chat/comments without human review
- Guarantee 100% accuracy to users
- Ignore legal compliance requirements
- Skip testing in your specific context
Use Cases #
✅ Recommended For:
- Food names and brand names
- Product titles and descriptions
- Usernames and display names
- Form inputs (limited scope)
- First-pass content filtering
⚠️ Requires Human Moderation:
- User chat messages
- Comments and reviews
- User-generated articles
- Social media posts
- Any content where context matters
Performance #
- Latency: <5ms on average
- Offline: No external API calls
- Privacy: All processing happens locally
- Tests: 870+ comprehensive tests
Contributing #
Contributions are welcome! Please:
- Test thoroughly with edge cases
- Follow existing code style
- Update documentation
- Add tests for new features
Support #
- Issues: Report bugs or request features via GitHub issues
- Email: [email protected]
- Website: https://mofilo.app
License #
MIT License - Copyright (c) 2025 Mofilo
See LICENSE for full terms.
Legal Disclaimer #
READ DISCLAIMER.md BEFORE USING THIS PACKAGE.
This software is provided "AS IS" without warranty of any kind. Mofilo is not liable for any damages, legal claims, or consequences arising from the use or failure of this software. Users are solely responsible for content moderation in their applications.
Published by Mofilo | mofilo.app