From 2a4079e9f8cc30e0badfeb8be4945a5f85b3a04a Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:21:32 -0800 Subject: [PATCH] Keep SSNs with "is", "Bearer:" values and codes in capitals private, and let West Point through "ssn is 123456" and a masked "ssn: xxx-xx-1234", "Bearer: island", codes in capitals after their label ("OTP ABCDEF", "PIN ABCD", any CVV), a document number or ID right after its colon, "lockbox number 4821", a UK National Insurance number in lower case and an IPv6 host in a link are private. A recovery phrase starting with "find" or holding "please" (both on its word list) is caught. "Point" is not read as a spelled dot, so "meet at West Point tomorrow" is looked up, and Idaho's code follows a town written in any case ("BOISE ID 83702", "Coeur d'Alene ID 83814"). Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 14 +++---- src/search/placeSuggestions.js | 60 ++++++++++++++++------------ src/search/placeSuggestions.test.mjs | 25 +++++++++++- 3 files changed, 66 insertions(+), 33 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 3c8fea39b4..3ba93c795a 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8049,11 +8049,8 @@ gmail.com") (an email address or a handle, also while it is typed; spaced, as in Chandambylu", it is part of a name); an email spelled around a filter ("john(at)gmail.com", "john[at]gmail[dot]com", "john at gmail dot de", "john at gmail.com", "john at gmail (dot) com"); an IP address -("10.0.0.1", "::1", "fe80::1"); a wallet's recovery phrase (12, 15, 18, 21 -or 24 lower-case words of three to eight letters, not starting as a request -does); a line that is one lower-case word of twenty letters or more (a -passphrase run together; one written with a capital, or spaced into words, -cannot be told from a name and is not caught); seven digits or more with nothing but spaces, +("10.0.0.1", "::1", "fe80::1", "https://[::1]/"); a wallet's recovery +phrase (see below); seven digits or more with nothing but spaces, punctuation, symbols or format characters between them (a phone, card, SSN or account number or its start: "+1 415 555", "4111 1111", "123 45 6789", "123456789", "4111.1111.1111.1111", "123–45–6789"; a street address's house number @@ -8127,8 +8124,11 @@ spaced UK National Insurance number and "my id is …" are private too. "Boise ID 83702" names Idaho. Some private text is not caught: a passphrase run together as one word (a long place name is one word too), a lower-case word after "otp", "2fa" or "mfa" ("mfa boston" is a name; -"otp ABCDEF" is caught) and a code of letters after "pin" or "gate code". -A Japanese postcode after a Latin name is refused ("Shibuya 150-0002"). Text that parses as coordinates or a +"otp ABCDEF" is caught) and a code of lower-case letters after "pin" or +"gate code" ("PIN ABCD" is caught). +A Japanese postcode after a Latin name is refused ("Shibuya 150-0002"), and +so is a name in capitals after a code's label ("MFA BOSTON", which cannot +be told from "OTP ABCDEF"). Text that parses as coordinates or a grid reference is not private. A place's name is six words at most, or ten when it has a number in it (an address: "1600 Pennsylvania Ave NW Washington DC 20500"). The places picked from the Omnibar's rows and chips that carry a position diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index 075ab4d571..c0389d817d 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -67,10 +67,6 @@ export function onlyNumbersLookPrivate(text) { ); } -/** How a typed request starts, unlike a recovery phrase's first word. */ -const REQUEST_START = - /^(?:show|hide|turn|switch|find|search|go|fly|take|zoom|open|close|play|what|where|when|which|who|how|why|list|display|enable|disable|remove|clear|follow|track)\b/; - /** * The most words a line sent for place suggestions may have: as many as the * Omnibar reads as a place's name (ten with a number, as an address has). @@ -94,20 +90,20 @@ const NOT_SEED_WORDS = new Set([ 'would', 'could', 'should', - 'please', 'does', 'was', 'were', 'flights', - 'show', ]); /** - * "Boise ID 83702": Idaho's code before a ZIP code, after a town's name - * (not after "My" or "Employee", whose "ID" is an identity number). + * "Boise ID 83702", "Coeur d'Alene ID 83814": Idaho's code before a ZIP + * code, after a town's name (not after "my" or "employee", whose "ID" is an + * identity number). */ -const IDAHO_BEFORE_ZIP = - /(?<=(?:^|\s)(?!(?:My|Your|Our|His|Her|Their|Employee|Student|Staff|Member|User|Customer|Patient|National|Voter|Photo|Tax|Card)\b)\p{Lu}\p{Ll}+,?\s)ID(?=\.?,?\s+\d{5}(?:-\d{4})?(?!\S))/gu; +const IDAHO_BEFORE_ZIP = /(\S+)(,?\s)ID(?=\.?,?\s+\d{5}(?:-\d{4})?(?!\S))/gu; +const ID_OWNERS = + /^(?:my|your|our|his|her|their|employee|student|staff|member|user|customer|patient|national|voter|photo|tax|card|the|an?)$/i; /** * Words that say a number is an account, a card, a phone or a secret, in the @@ -129,7 +125,9 @@ function foldLine(text) { .replace(/[\u2018\u2019]/g, "'") .replace(/(?![0-9])\p{Nd}/gu, '0') .replace(/\s+/g, ' ') - .replace(IDAHO_BEFORE_ZIP, 'Idaho'); + .replace(IDAHO_BEFORE_ZIP, (whole, word, gap) => + ID_OWNERS.test(word) ? whole : `${word}${gap}Idaho`, + ); } /** A US ZIP+4 after a state's code or name, as an address writes it. */ @@ -175,7 +173,7 @@ function privacyReason(text) { return 'other'; if ( /[\p{L}\p{N}._%+-]\s*[([{<]\s*at\s*[)\]}>]\s*[\p{L}\p{N}-]/iu.test(line) || - /\b\S+\s+at\s+\S+\s+(?:dot|punto|ponto|period|point|punkt|[([{<]\s*dot\s*[)\]}>])\s+\p{L}{2,24}\b/iu.test( + /\b\S+\s+at\s+\S+\s+(?:dot|punto|ponto|period|punkt|[([{<]\s*dot\s*[)\]}>])\s+\p{L}{2,24}\b/iu.test( line, ) || /\b\S+\s+at\s+[\p{L}\p{N}-]+\s*[([{<]\s*dot\s*[)\]}>]\s*\p{L}{2,24}\b/iu.test( @@ -186,6 +184,8 @@ function privacyReason(text) { ) ) return 'other'; + // An IPv6 host in a link ("https://[::1]/"). + if (/\[[0-9a-f:.]*:[0-9a-f:.]*:[0-9a-f:.]*\]/i.test(line)) return 'other'; // An IP address ("10.0.0.1"). if (/(?= 12 && words.length <= 24 && words.every((word) => /^[a-z]{3,8}$/.test(word)) && - !words.some((word) => NOT_SEED_WORDS.has(word)) && - !REQUEST_START.test(words[0]) + !words.some((word) => NOT_SEED_WORDS.has(word)) ) return 'other'; // Coordinates and grid references are a spot, not a number to keep: only @@ -278,7 +277,7 @@ function privacyReason(text) { // but a capitalised name is a token, and a social security number has // digits. bearerToken(line) || - /\bssn\b\s*[:=#]?\s*\d/i.test(line) || + /\bssn\b(?:\s+(?:is|no\.?|number|#))*\s*[:=#]?\s*[\dx*]{3}/i.test(line) || // The word for "password" in the interface's languages. // A whole word only: "Sachsenhausen" holds "senha" but is a place. /(? { 'zip code 90210', 'area code 415', 'Settipalle @ K.Bandarlapalle', + 'boise ID 83702', + "Coeur d'Alene ID 83814", + 'meet at West Point tomorrow', + 'OTP Bank', + 'GATE CODE LANE', // Questions for the assistant, however many short words they have. 'can you tell where the most flights are going over texas today', 'are there any storms near florida right now that might cause delays',