Skip to content

fix: reject profanity matches inside hex/UUID tokens (#23) - #40

Merged
deemonic merged 2 commits into
mainfrom
fix/uuid-hex-false-positive
Jan 27, 2026
Merged

deemonic merged 2 commits into
mainfrom
fix/uuid-hex-false-positive

Conversation

@deemonic

@deemonic deemonic commented Jan 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds isInsideHexToken() guard in BlaspService::handle() that skips profanity matches found inside UUIDs, MD5/SHA hashes, and other long hex strings
  • Fixes UUID flagged as profanity #23 where UUID 6ec3e80f-11ad-3d5c-809f-144a2ef5800b was flagged because 800b mapped to boob via character substitutions
  • Adds 10 tests covering UUIDs, hex strings, MD5 hashes, and edge cases ensuring normal profanity detection is unaffected

Test plan

  • All 164 existing tests pass
  • UUID alone not flagged
  • UUID in sentence not flagged
  • Multiple UUIDs not flagged
  • MD5 hash not flagged
  • Long hex string with digits not flagged
  • Profanity alongside UUID still detected
  • Standalone profanity (boob, ass, shit) still detected
  • Short hex tokens don't suppress profanity
  • Pure-letter hex tokens don't suppress profanity

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Reduced false positives by ensuring UUIDs and hex-like tokens are ignored during profanity checks.
  • Tests

    • Added tests covering UUIDs, various hex-like strings, hashes, and mixed cases to verify profanity detection remains accurate.

✏️ Tip: You can customize this high-level summary in your review settings.

UUIDs like `6ec3e80f-...-144a2ef5800b` were flagged because `800b`
mapped to `boob` via character substitutions. Add an `isInsideHexToken`
guard that skips matches embedded in UUIDs, MD5/SHA hashes, and other
long hex strings while leaving normal profanity detection intact.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jan 27, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a pre-filter in profanity detection to skip matches that occur inside UUIDs or hex-like tokens, implemented via a new private method isInsideHexToken() in BlaspService and covered by new unit tests for UUID/hex edge cases.

Changes

Cohort / File(s) Summary
Core Implementation
src/BlaspService.php
Added private method isInsideHexToken() and invoked it in handle() to skip profanity matches that are inside UUIDs or long hex-like tokens (expands token, trims hyphens, detects UUID pattern or long hex with digits). Preserved existing word-boundary logic.
Test Coverage
tests/UuidFalsePositiveTest.php
New test class Blaspsoft\Blasp\Tests\UuidFalsePositiveTest (10 tests) validating that UUIDs and hex-like strings are not flagged, while profanity detection still triggers when profane words are present alongside or outside such tokens.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through strings both short and long,
I sniffed a UUID and hummed a song,
“No foul here,” I sighed, with careful art,
We skip hex tokens and keep true parts,
Hooray for cleaner checks — a happy heart!

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: reject profanity matches inside hex/UUID tokens (#23)' accurately summarizes the main change: adding a filter to skip profanity matches inside hex/UUID tokens, directly addressing the linked issue.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #23: rejecting profanity matches inside UUIDs and hex-like tokens via an isInsideHexToken() method, with comprehensive tests validating UUID/hex handling and preserved profanity detection.
Out of Scope Changes check ✅ Passed All changes directly support the objective to fix UUID false positives: the isInsideHexToken() implementation in BlaspService.php and comprehensive test coverage in UuidFalsePositiveTest.php align with issue #23 requirements without extraneous modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/UuidFalsePositiveTest.php`:
- Around line 46-59: Update the two tests so the inputs actually place the
profanity as a substring of the hex-like tokens described: in
test_short_hex_does_not_suppress_profanity call Blasp::check with a short
hex-like token containing "ass" (e.g. "abass" or "abcass12" — any token shorter
than the long-hex guard threshold) and assert hasProfanity() is true; in
test_pure_letter_hex_does_not_suppress_profanity call Blasp::check with a
pure-letter hex token containing "boob" (e.g. "deadbeefboob" or "boobdeadbeef")
and assert hasProfanity() is true so the tests exercise the intended guard
behavior.

Comment thread tests/UuidFalsePositiveTest.php
Use actual hex-like inputs (800b, deadbeef) instead of plain profanity
strings so the tests exercise the guard behavior they describe.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@deemonic
deemonic merged commit dffff5b into main Jan 27, 2026
3 checks passed
@deemonic
deemonic deleted the fix/uuid-hex-false-positive branch January 27, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UUID flagged as profanity

1 participant