simplygoodwork / curses
A lightweight, developer-focused profanity filter for Craft CMS
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 2
Type:craft-plugin
pkg:composer/simplygoodwork/curses
Requires
- php: ^8.0.2
- craftcms/cms: ^4.0|^5.0
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
- craftcms/rector: dev-main
This package is auto-updated.
Last update: 2025-12-04 11:35:22 UTC
README
Curses!
Plugin for Craft CMS
A lightweight, developer-focused profanity filter for Craft CMS. Detect and mask inappropriate content in your frontend templates using advanced pattern matching.
Features
- Twig Filters -
maskProfanityandhasProfanityfor template use - Advanced Pattern Matching - Detects variations including substitutions, obscured text, and repeated letters
- Config-Based - Customize the word list via a simple config file
Requirements
- Craft CMS
4.0.0or later - PHP
8.0.2or later
Installation
composer require simplygoodwork/curses
Then install the plugin from the Control Panel or run:
php craft plugin/install curses
Usage
Twig Filters
maskProfanity
Masks profanity in text using the configured mask character (default *):
{{ entry.body|maskProfanity }}
{# Output: "This is some **** text" #}
{# Override mask character for this call #}
{{ entry.body|maskProfanity('#') }}
{# Output: "This is some #### text" #}
hasProfanity
Check if text contains profanity:
{% if entry.body|hasProfanity %}
<p class="warning">This content may contain inappropriate language.</p>
{% endif %}
{# As a function #}
{% if hasProfanity(entry.body) %}
{# ... #}
{% endif %}
Configuration
The plugin comes with a blank list of words. To customize:
- Copy
vendor/simplygoodwork/curses/src/config.phptoconfig/curses.php - Modify the settings as needed
// config/curses.php return [ // Character used to mask profanity (default: '*') // Set to an empty string '' to remove profanity entirely instead of masking 'maskCharacter' => '*', // Your word list 'profanities' => [ 'word1', 'word2', // ... ], ];
The config file is multi-environment aware, so you can have different settings per environment.
Pattern Matching
The plugin detects various obfuscation techniques:
- Straight Match:
profanity - Substitution:
pr0f@n1ty(common letter replacements like a→@, e→3, i→1) - Obscured:
p-r-o-f-a-n-i-t-y(with separators like -, _, .) - Doubled:
pprrooffaanniittyy(repeated letters) - Combined:
p-r0f@n|tty(mix of techniques)
Performance
- Request-level caching - Patterns are compiled once per request
- Efficient regex - Single-pass matching for all word variations
- No database queries - Words loaded from config file
Changelog
See CHANGELOG.md
Support
Submit an issue on GitHub.
Brought to you by Good Work