Skip to content

v4.0.0

Choose a tag to compare

@deemonic deemonic released this 26 Mar 12:51
· 5 commits to main since this release
a6758c9

Blasp v4.0.0

A ground-up rewrite with a driver-based architecture, severity scoring, and deep Laravel integration.

New Features

  • Driver-based architecture β€” regex (obfuscation/substitution detection), pattern (fast exact matching), phonetic (sound-alike evasion via metaphone + Levenshtein), and pipeline (chain multiple drivers together). Extend with custom drivers.
  • Severity scoring β€” Profanities categorised as mild/moderate/high/extreme with per-word weights and a 0–100 composite score. Filter by minimum severity threshold.
  • Multi-language support β€” English, Spanish, German, French with language-specific normalizers and severity maps. Check one, many, or all at once via fluent API.
  • Masking strategies β€” Character mask (*, #), grawlix (!@#$%), or a custom callback.
  • Eloquent integration β€” Blaspable trait auto-sanitizes or rejects profanity on model save, with withoutBlaspChecking() for bypassing.
  • Middleware β€” CheckProfanity middleware to reject or sanitize profane request fields with configurable severity and field filtering.
  • Validation rule β€” blasp_check rule with language support.
  • Blade directive β€” @clean($text) for output sanitization.
  • Str/Stringable macros β€” Str::isProfane(), Str::cleanProfanity(), and Stringable equivalents.
  • Result caching β€” Configurable cache driver, TTL, and key eviction.
  • Events β€” ProfanityDetected, ContentBlocked, ModelProfanityDetected.
  • Testing utilities β€” Blasp::fake() for test doubles with assertions.

Breaking Changes

  • Namespace flattened β€” Blaspsoft\Blasp\Laravel\ merged into Blaspsoft\Blasp\. Update any direct class references.
  • Service provider renamed β€” ServiceProvider β†’ BlaspServiceProvider (auto-discovery handles this).
  • Config file renamed β€” config/config.php β†’ config/blasp.php. Re-publish with php artisan vendor:publish --tag="blasp-config".
  • API changes β€” check() now returns a Result object with isOffensive(), clean(), score(), severity(), count(), words(), uniqueWords(). Previous methods like hasProfanity(), getCleanString(), getProfanitiesCount() are removed.

Compatibility

  • PHP 8.2+
  • Laravel 8.0 – 13.x

Full Changelog

v3.1.9...v4.0.0