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

1.0.0 2025-12-03 19:23 UTC

This package is auto-updated.

Last update: 2025-12-04 11:35:22 UTC


README

Curses icon

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 - maskProfanity and hasProfanity for 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.0 or later
  • PHP 8.0.2 or 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:

  1. Copy vendor/simplygoodwork/curses/src/config.php to config/curses.php
  2. 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