Skip to content

feat: add word-boundary guards for ASCII surfaces to prevent partial replacements#7

Open
pratik1258m wants to merge 1 commit into
fishonbike:mainfrom
pratik1258m:feat/latin-word-boundary-guards
Open

feat: add word-boundary guards for ASCII surfaces to prevent partial replacements#7
pratik1258m wants to merge 1 commit into
fishonbike:mainfrom
pratik1258m:feat/latin-word-boundary-guards

Conversation

@pratik1258m

Copy link
Copy Markdown

This pull request addresses issue #3 by introducing word-boundary guards (\b) for ASCII surfaces during replacement. This improves precision for Latin text by ensuring literal substrings do not accidentally match and get replaced inside longer words (e.g. preventing 'Jack' from replacing inside 'jackpot' or 'hijack'). Chinese and other CJK text remain unaffected.

Changes:

  1. Updated the apply method in vaultengine/mapping.py to check if the surface starts and ends with an ASCII word character, and if so, perform the replacement using a regular expression anchored by word boundaries (\b).
  2. Added unit tests in tests/test_mapping.py to verify that partial word replacements are prevented for ASCII surfaces while full word matches succeed and CJK replacements remain unaffected.

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.

1 participant