Repository navigation
v4.3.2
A hardening release from a full review of v4.3.1. Everything here stops input from tying up a worker, fixes output that was wrong, or speeds checks up. Results for normal text are unchanged: a differential run of 3,337 texts against v4.3.1 found no new and no lost detections. No API changes. (#57)
Security
- Crafted input could stall a worker. A few KB of text like
aaaa…,!!!!…oro*o*…made checks take seconds to minutes. This was reachable through the middleware, the validation rule andBlaspable. Checks now scale linearly: 2 KB ofawent from 10.5 s to 31 ms. - Fail-open on PCRE errors. When PCRE gave up on a long text, it passed as clean; for example,
'!' x 2000 . ' you lickme'was not flagged. The text is now rescanned in windows instead. - An empty block-list word hung forever. This includes
block(''), orexplode(',', env(...))returning['']. Blank words are now ignored. - Invalid UTF-8 crashed the pipeline driver (a 500 through the middleware) and stopped invisible characters being stripped.
Bug Fixes
- Repeated accented words are masked correctly:
"fück fück"was"**** f***". Later words are no longer missed either. - Accented matches no longer spill into the next word:
"fück and shit"was"******nd ****". - Pattern driver positions are correct for text whose lowercase changes length (
İ). - Result cache:
- It now respects config changes, language-file edits and package upgrades. Changing allow/block lists, mask, language, separators, substitutions or driver config previously served stale results for up to 24 h.
blasp:clearnow clears every cached result.
ProfanityDetectednow fires on cached checks too.Blaspable:- Encrypted attributes are checked as plain text, not ciphertext.
array/jsonattributes are no longer corrupted on save.
- Testing helpers:
Blasp::withoutFiltering()turns filtering back on afterwards.- Routes using the
blaspmiddleware work afterBlasp::fake().
strict()now forces the regex driver, as documented.Profanity::in(),::maxScore()and::severity()work statically, as documented, and still chain on an instance.
Performance
- Short checks: about 1 ms instead of about 15 ms.
inAllLanguages(): about 22 ms instead of about 140 ms.- Long or dense text: 64 KB of dense profanity takes 0.55 s instead of about 8 s.
Tip: cap input length before checking, e.g. ['bail', 'string', 'max:5000', Profanity::in('english')].