From 5c2d0c709e140a4012486184e97a664be07a730e Mon Sep 17 00:00:00 2001 From: Shanu Date: Thu, 20 Aug 2026 15:48:11 +0530 Subject: [PATCH] docs(pii): state the case the CJK substring tier actually covers; drop two loose bare keywords MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post-approval notes from #154 review: the CJK-tier comment claimed the tier helps when digits directly follow a CJK word, but in exactly that case CC_RE's leading word-boundary already fails (CJK is a word character) and the run is never a candidate — the tier earns its place on keyword-embedded-in-sentence text. Also drop bare `elo` and `maestro` from the standalone keyword list: both networks are covered structurally by the IIN table, and as English words they are looser than the rest of the list. --- src/memory/store/safety/pii.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/memory/store/safety/pii.rs b/src/memory/store/safety/pii.rs index a552fde..d8fbe8c 100644 --- a/src/memory/store/safety/pii.rs +++ b/src/memory/store/safety/pii.rs @@ -122,11 +122,14 @@ static CC_RE: LazyLock = // `panNumber` all lowercase into these. // * Native-script terms, per this module's multilingual mandate (the Aadhaar // and My Number patterns already carry theirs). CJK terms match as -// substrings — CJK text does not put `[\W_]` between a word and the -// digits that follow it. +// substrings because CJK sentences provide no `[\W_]` boundaries around a +// word — the case this buys is a keyword embedded mid-sentence +// (`…信用卡账单 `). It does not buy `卡号` with the digits +// directly attached: there `CC_RE`'s own leading `\b` already fails +// (CJK is `\w`), so the run is never a candidate in the first place. static CC_KEYWORD_RE: LazyLock = LazyLock::new(|| { Regex::new( - r"(?i)(?:^|[\W_])(?:card|credit|debit|visa|mastercard|amex|american\s?express|discover|jcb|diners|unionpay|maestro|hipercard|elo|rupay|cvv|cvc|cc|pan|tarjeta|cart[aã]o|carte|karte|карта|карты|карту|картой|карте|кредитка)(?:[\W_]|$)|(?i:cardnumber|creditcard|ccnum|cardno|pannumber|カード|信用卡|卡号|银行卡|카드)", + r"(?i)(?:^|[\W_])(?:card|credit|debit|visa|mastercard|amex|american\s?express|discover|jcb|diners|unionpay|hipercard|rupay|cvv|cvc|cc|pan|tarjeta|cart[aã]o|carte|karte|карта|карты|карту|картой|карте|кредитка)(?:[\W_]|$)|(?i:cardnumber|creditcard|ccnum|cardno|pannumber|カード|信用卡|卡号|银行卡|카드)", ) .expect("cc keyword") });