From 8885177e2e9c72c69f19f3c4f76f5e4915f47c06 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 16:50:46 -0800 Subject: [PATCH 01/14] Keep spelled-out emails, IP addresses, recovery phrases and lower-case codes from the place service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Place suggestions still sent "john(at)gmail.com", "10.0.0.1", a wallet's recovery phrase, a passphrase run together, "license ABC1234", lower-case codes after a code label ("otp abcdef", "cvv abc") and short phone numbers read as an address ("Jo 12345-6789", "Mo 0171 12345"), and a phone's three and four digits could still be searched as a place on purpose. They now stay in the browser. Real places that only looked private are looked up again: Akiak, Bearer Island, SSN Station, Shibuya 150-0002. A suggested house is named in its country's order ("Hauptstraße 12"), and one without a street keeps its number. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 42 +++++++--- src/search/placeSuggestions.js | 114 ++++++++++++++++++++++++--- src/search/placeSuggestions.test.mjs | 84 ++++++++++++++++++++ 3 files changed, 218 insertions(+), 22 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 64207f325a..d52899c213 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8043,44 +8043,64 @@ digits and "@" count, and digits of any script count as digits. It is any line with: an "@" with something right on both sides, ending a word, starting a lowercase handle ("@jdoe"), or spaced before a domain ("john @ gmail.com") (an email address or a handle, also while it is typed; spaced, as in "Nanjampeta @ -Chandambylu", it is part of a name); seven digits or more with nothing but spaces, +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"); an +IP address ("10.0.0.1"); a wallet's recovery phrase (12, 15, 18, 21 or 24 +different lower-case words of three to eight letters); a line that is one +lower-case word of twenty letters or more (a passphrase run together); 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 -and its postcode are read apart: five digits, or between the street and +and its postcode are read apart (a house number never starts with 0, and +a polite word such as "thanks" after the digits is not a city): five digits, or between the street and the city "00-950", "111 21", "125009", "1100-053", or four digits after a -comma ("Straße 120, 1070 Wien"); and so are a US ZIP+4 after a word, -a Brazilian CEP, a Japanese postcode after "〒" or before the address, and +comma ("Straße 120, 1070 Wien"); and so are a US ZIP+4 after a state's +code or name ("Alice 12345-6789" and "Jo 12345-6789" stay private), +a Brazilian CEP, a Japanese postcode after "〒", before the address or +after a place's name ("Shibuya 150-0002"), and digits on either side of "#", so "Hauptstrasse 12 10115 Berlin", "DC 20500-0003", "〒100-0001 東京都千代田区" and "Calle 100 # 19-61" are places, while a seven-digit postcode alone such as "Tel Aviv 6100000" still reads as private); a phone number written with dots; two letters, two digits and ten more letters or digits (an IBAN's shape); "password", -"passcode", "passwd", "ssn", "pw", "pwd" or "bearer" followed by anything, -"token", "secret", "api key", "key" or "pass" followed by ":" or "=", a +"passcode", "passwd", "pw" or "pwd" followed by anything, "bearer" +followed by anything but a capitalised name ("Bearer Island" is a place), +"ssn" followed by a digit ("SSN Station" is a place), "token", "secret", +"api key", "key" or "pass" followed by ":" or "=", a licence, plate, +passport, membership, account, policy, ticket, booking, confirmation or +reference number with letters and digits after its label ("license +ABC1234"), "otp", "2fa", "mfa", "cvv", "cvc" or a verification, one-time, +security, auth or login code followed by a code in any case that is not a +capitalised name ("otp abcdef"; "OTP Bank" is a place), a door, access, gate, alarm, entry or security code followed by a digit, "api key", "access token" or "secret key" followed by a word of six characters or more, the word for "password" in the interface's languages (contraseña, Passwort, mot de passe, пароль…) followed by anything, or "pin" (also "pin code", "pin number", "pin is") followed by a digit; a word starting `sk_`, `sk-`, `rk_`, `pk_live`, `ghp_` or a Slack token's `xoxb-` and the like (any case) or -`AIza`, `eyJ` or `AKIA`; or a word that may be a password or key, with letters and digits mixed +`AIza` or `eyJ`, or an AWS key id (`AKIA` and twelve capitals or digits +more; "Akiak" is a place); or a word that may be a password or key, with letters and digits mixed within one run (a number beside a word, as in "Yanino-1", "2-chōme" or "Route-66", is a name): eight characters or more, six or more with four letters and a digit ("hunter22", "Area51"), or six or more with letters, digits and a symbol ("Tr0ub4dor&3"). The password words match whole words -only ("Sachsenhausen" is a place). Over the bundled names (139,502), five -read as private: two with stray digits ("Maliga0N", "Jerónim67") and three -with number lists or codes. When the text may be private the field says +only ("Sachsenhausen" is a place). Over the bundled names (139,502), six +read as private: two with stray digits ("Maliga0N", "Jerónim67"), two +joined by "@" to a lower-case handle ("Pulipadu @Govardhanagiri") and two +with number lists or dates. When the text may be private the field says so ("Looks private, so nothing is searched or sent"), and a line whose only private sign is an address-sized run of digits (no group over six -digits, nine at most in all, counted as they fold, and no word such as +digits, nine at most in all, counted as they fold, no three digits +followed by four as a phone number writes them, and no word such as card, code, key, phone or account beside them, in English and some other European languages; compounds such as "Kreditkartennummer" and words in other scripts are not read), with words beside it, gets a row to search it as a place on purpose ("Search … as a place anyway"), which runs the ordinary place search and its online services only when picked; a bare number, an email or handle, a password, key, code or IBAN gets none. +A suggested house is named by its number and its street (or, without a +street, its locality) in the order its country writes them: "10 Downing +Street", "Hauptstraße 12". A nine-digit number or a short phone number written with no such word still gets the row: only picking it sends anything. One-time and verification codes, OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index 6fa20b11b5..d65f21d9de 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -62,6 +62,7 @@ export function onlyNumbersLookPrivate(text) { // is ("card 4111 …", "phone +1 415 …", "token 12345678"). groups.every((group) => group.length <= 6) && groups.join('').length <= 9 && + !/(?]\s*[\p{L}\p{N}-]/iu.test(line) || + /\b\S+\s+at\s+\S+\s+dot\s+\p{L}{2,6}\b/iu.test(line) + ) + return 'other'; + // An IP address ("10.0.0.1"). + if (/(? /^[a-z]{3,8}$/.test(word)) + ) + return 'other'; + // A passphrase run together ("correcthorsebatterystaple"): a line that + // is one word of twenty letters or more, all lower case. A long place + // name is written with its capital ("Llanfairpwllgwyngyll"), and a long + // word inside a name ("… selskokhozyaystvennoy opytnoy stantsii") has + // others beside it. + if (words.length === 1 && /^[a-z]{20,}$/.test(words[0])) return 'other'; // Coordinates and grid references are a spot, not a number to keep: only // text the place search itself reads as coordinates, as typed ("١٢٣٤, // ٥٦٧٨" folded would read as a spot, but is not one). @@ -146,7 +172,7 @@ function privacyReason(text) { .replace( // After a street word, or before the city ("12, 10115 Berlin"); // "030 12345" alone is a phone number. - /(?<=\p{L}\.?\s)\d{1,4}[a-z]?,?\s+\d{5}(?:-\d{3})?(?=\s+\p{L}|$)|(?<=^|\s)\d{1,4}[a-z]?,?\s+\d{5}(?:-\d{3})?(?=\s+\p{L})/giu, + /(?<=\p{L}\.?\s)[1-9]\d{0,3}[a-z]?,?\s+\d{5}(?:-\d{3})?(?=\s+(?!(?:thanks|thank|thx|please|pls|ok|okay|now|asap|call|text)\b)\p{L}|$)|(?<=^|\s)[1-9]\d{0,3}[a-z]?,?\s+\d{5}(?:-\d{3})?(?=\s+(?!(?:thanks|thank|thx|please|pls|ok|okay|now|asap|call|text)\b)\p{L})/giu, ' ', ) // Other postcodes after a street's house number and before the city (a @@ -164,7 +190,7 @@ function privacyReason(text) { .replace(US_ZIP4, ' x ') .replace(/\b\d{5}-\d{3}\b/g, ' x ') .replace( - /〒\s?\d{3}-\d{4}|\b\d{3}-\d{4}(?=\s*[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}])/gu, + /〒\s?\d{3}-\d{4}|\b\d{3}-\d{4}(?=\s*[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}])|(?<=\p{L}{3,},?\s)\d{3}-\d{4}(?=\s*$|,)/gu, ' x ', ) .replace(/#/g, ' x ') @@ -176,9 +202,12 @@ function privacyReason(text) { // An IBAN. if (/\b[a-z]{2}\d{2}(?:\s?[a-z0-9]){10,}/i.test(line)) return 'other'; if ( - /\b(?:password|passcode|passwd|ssn|pw|pwd|bearer)\b\s*[:=#]?\s*\S/i.test( - line, - ) || + /\b(?:password|passcode|passwd|pw|pwd)\b\s*[:=#]?\s*\S/i.test(line) || + // "Bearer Island" and "SSN Station" are places: after "bearer" any value + // but a capitalised name is a token, and a social security number has + // digits. + bearerToken(line) || + /\bssn\b\s*[:=#]?\s*\d/i.test(line) || // The word for "password" in the interface's languages. // A whole word only: "Sachsenhausen" holds "senha" but is a place. /(? /^(?:sk[-_]|rk_|pk_live|ghp_|xox[abposr]-)/i.test(token) || - /^(?:AIza|eyJ|AKIA)/.test(token) || + /^(?:AIza|eyJ)/.test(token) || + /^AKIA[0-9A-Z]{12,}$/.test(token) || mayBeSecret(token), ) ) @@ -224,6 +259,12 @@ function privacyReason(text) { return longNumber ? 'number' : null; } +/** A value after "bearer" that is not a capitalised name ("Bearer Island"). */ +function bearerToken(line) { + const match = /\bbearer\b\s*[:=#]?\s*(\S+)/i.exec(line); + return Boolean(match) && !/^\p{Lu}\p{Ll}+$/u.test(match[1]); +} + /** * A code after a label that can only be a code, without a colon ("PIN * A7B2", "verification code ABCDEF", "otp 7GH2K"): holding a digit, or in @@ -231,6 +272,14 @@ function privacyReason(text) { * "GATE CODE LANE", "OTP Bank" and "Auth Code ABCD Street" stay places. */ function codeAfterLabel(line) { + // Labels that only ever name a code take one in lower case too ("otp + // abcdef", "cvv abc", "verification code abcdef"); a capitalised word + // after them is a name ("OTP Bank", "MFA Boston"). + const coded = + /\b(?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?\s+([a-z0-9][a-z0-9-]{2,})\s*[.!]?\s*$/i.exec( + line, + ); + if (coded && !/^\p{Lu}(?:\p{Ll}+|\p{Lu}+)$/u.test(coded[1])) return true; const match = /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,})\s*[.!]?\s*$/i.exec( line, @@ -292,6 +341,43 @@ export function resetPlaceSuggestions() { shared.pending.clear(); } +/** + * Countries that write a house's number before its street ("10 Downing + * Street", "12 rue de Rivoli"); elsewhere it follows ("Hauptstraße 12"). + */ +const NUMBER_FIRST = new Set([ + 'US', + 'CA', + 'GB', + 'IE', + 'AU', + 'NZ', + 'FR', + 'LU', + 'MC', + 'ZA', + 'IN', + 'PH', + 'SG', + 'MY', + 'HK', + 'TH', + 'LK', + 'NG', + 'GH', + 'KE', + 'JM', + 'TT', +]); + +/** A house's number and street as its country writes them, or ''. */ +export function houseAddress({ houseNumber, street, countryCode }) { + if (!houseNumber || !street) return ''; + return NUMBER_FIRST.has(String(countryCode || 'US').toUpperCase()) + ? `${houseNumber} ${street}` + : `${street} ${houseNumber}`; +} + /** List Photon candidates while typing. The submitted search owns navigation. */ export function createPlaceSuggester({ endpoint, @@ -384,11 +470,17 @@ export function createPlaceSuggester({ type, street, housenumber: houseNumber, + locality, + district, } = feature.properties ?? {}; - // A house has no name of its own: its street and number are its - // name, so two houses on one street stay two places. - const address = - street && houseNumber ? `${houseNumber} ${street}` : ''; + // A house has no name of its own: its street (or, without one, its + // locality) and number are its name, written in the country's own + // order, so two houses on one street stay two places. + const address = houseAddress({ + houseNumber, + street: street || locality || district || city, + countryCode, + }); const name = normalized.name || address || city || state || country; if (!name) continue; const detail = [...new Set([city, state, country])] diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index 7063008116..c2a958d2fc 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -3,8 +3,10 @@ import test from 'node:test'; import { citiesInRegion, createPlaceSuggester, + houseAddress, inExtent, mayBePrivate, + onlyNumbersLookPrivate, resetPlaceSuggestions, } from './placeSuggestions.js'; @@ -427,3 +429,85 @@ test('the same text asked again while its request is out is sent once', async () await Promise.all([service.suggest('Paris'), service.suggest('Paris')]); assert.equal(sent, 1); }); + +test('spelled-out emails, addresses, phrases, codes and short phone numbers stay private', () => { + for (const line of [ + 'john(at)gmail.com', + 'john[at]gmail[dot]com', + 'john at gmail dot de', + '10.0.0.1', + 'abandon ability able about above absent absorb abstract absurd abuse access accident', + 'correcthorsebatterystaple', + 'license ABC1234', + 'passport X1234567', + 'plate 7ABC123', + 'otp abcdef', + 'verification code abcdef', + 'cvv abc', + 'Bearer abcdef', + 'ssn 123', + 'Jo 12345-6789', + 'Joe 1234 12345 thanks', + 'Mo 0171 12345', + ]) + assert.equal(mayBePrivate(line), true, line); + // A phone's three and four digits are not offered as an address. + assert.equal(onlyNumbersLookPrivate('is 555 0100 thanks'), false); +}); + +test('places that only looked private are looked up', () => { + for (const line of [ + 'Akiak', + 'Bearer Island', + 'SSN Station', + 'Shibuya 150-0002', + 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch', + 'OTP Bank', + // A long request is not a recovery phrase. + 'show flights over texas near austin with altitude above thirty thousand feet please', + 'show fires near austin then show flights above texas with labels please', + ]) + assert.equal(mayBePrivate(line), false, line); +}); + +test('a house is named by its number and street in the order its country writes them', async () => { + assert.equal( + houseAddress({ + houseNumber: '10', + street: 'Downing Street', + countryCode: 'gb', + }), + '10 Downing Street', + ); + assert.equal( + houseAddress({ + houseNumber: '12', + street: 'Hauptstraße', + countryCode: 'DE', + }), + 'Hauptstraße 12', + ); + assert.equal(houseAddress({ houseNumber: '12', street: '' }), ''); + // Without a street, a house's number and its locality name it, so two + // houses in one hamlet stay two places, not the city twice. + const house = (number) => ({ + geometry: { type: 'Point', coordinates: [11.2, 47.6] }, + properties: { + housenumber: number, + locality: 'Mittenwald Au', + city: 'Mittenwald', + country: 'Germany', + countrycode: 'de', + osm_value: 'house', + }, + }); + const service = createPlaceSuggester({ + endpoint: 'https://fixture.test/api/', + fetchImpl: async () => + Response.json({ features: [house('3'), house('5')] }), + }); + assert.deepEqual( + (await service.suggest('Mittenwald Au')).map((place) => place.name), + ['Mittenwald Au 3', 'Mittenwald Au 5'], + ); +}); From 35049fd7f7b658dd408e474db5025b0d2d1f14ba Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 16:59:35 -0800 Subject: [PATCH 02/14] Keep more shapes of phones, codes, tokens, emails and IP addresses private Review found "Alice 555-0100" sent as a Japanese postcode, recovery phrases with a repeated word, a capitalised bearer token, codes after a lower-case label in other cases ("verification code Abc", "PIN aBcD"), "john at gmail.com" and "(dot)" forms, passport numbers of digits only, "ID AB123" and IPv6 addresses. They now stay in the browser, and the suggester never sends a line of more than eight words. "Bearer Island, Canada", "bearer island", a ZIP+4 after two spaces and a Japanese postcode after Japanese script are looked up again. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 34 +++++---- src/search/placeSuggestions.js | 102 +++++++++++++++++++++++---- src/search/placeSuggestions.test.mjs | 52 +++++++++++++- 3 files changed, 161 insertions(+), 27 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index d52899c213..e22add909e 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8029,7 +8029,8 @@ and errors, keeping the separate Location draft intact. While typing, a short line (six words or fewer, no `?`, not a command, coordinates, a hex code, a callsign such as UAL2110 or N123AB, and nothing that may be private) is sent to -Photon for place suggestions: at most one request every 500 ms per tab, +Photon for place suggestions (the suggester itself never sends a line of +more than eight words): at most one request every 500 ms per tab, and none for a minute after a refusal. Photon is the keyless geocoder the place search already uses; a submitted search is not part of this spacing. A line that may be one name ("Satellite Beach") is looked up whole. While @@ -8044,10 +8045,13 @@ any line with: an "@" with something right on both sides, ending a word, starting a lowercase handle ("@jdoe"), or spaced before a domain ("john @ gmail.com") (an email address or a handle, also while it is typed; spaced, as in "Nanjampeta @ 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"); an -IP address ("10.0.0.1"); a wallet's recovery phrase (12, 15, 18, 21 or 24 -different lower-case words of three to eight letters); a line that is one -lower-case word of twenty letters or more (a passphrase run together); seven digits or more with nothing but spaces, +("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, 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 @@ -8056,22 +8060,28 @@ a polite word such as "thanks" after the digits is not a city): five digits, or the city "00-950", "111 21", "125009", "1100-053", or four digits after a comma ("Straße 120, 1070 Wien"); and so are a US ZIP+4 after a state's code or name ("Alice 12345-6789" and "Jo 12345-6789" stay private), -a Brazilian CEP, a Japanese postcode after "〒", before the address or -after a place's name ("Shibuya 150-0002"), and +a Brazilian CEP, a Japanese postcode after "〒" or next to the address in +Japanese script ("東京都千代田区100-0001"; after a Latin name, as in +"Shibuya 150-0002", it reads as a phone number), and digits on either side of "#", so "Hauptstrasse 12 10115 Berlin", "DC 20500-0003", "〒100-0001 東京都千代田区" and "Calle 100 # 19-61" are places, while a seven-digit postcode alone such as "Tel Aviv 6100000" still reads as private); a phone number written with dots; two letters, two digits and ten more letters or digits (an IBAN's shape); "password", "passcode", "passwd", "pw" or "pwd" followed by anything, "bearer" -followed by anything but a capitalised name ("Bearer Island" is a place), +followed by anything but a short capitalised name or a place word such as +island or lake ("Bearer Island", "bearer island" are places), "ssn" followed by a digit ("SSN Station" is a place), "token", "secret", "api key", "key" or "pass" followed by ":" or "=", a licence, plate, passport, membership, account, policy, ticket, booking, confirmation or -reference number with letters and digits after its label ("license -ABC1234"), "otp", "2fa", "mfa", "cvv", "cvc" or a verification, one-time, -security, auth or login code followed by a code in any case that is not a -capitalised name ("otp abcdef"; "OTP Bank" is a place), a +reference number with a digit after its label ("license ABC1234", +"passport no. 123456"), "ID" in capitals followed by a number ("ID +AB123"), "otp", "2fa", "mfa", "cvv", "cvc" or a verification, one-time, +security, auth or login code followed by a code (any value after a label +in lower case, "verification code Abc", also before "thanks"; after a label +written as a name, any value that is not one: "OTP Bank" and "Security +Code Plaza" are places), a "pin" or door, access, gate, alarm or entry +code followed by a value in mixed case ("PIN aBcD"), a door, access, gate, alarm, entry or security code followed by a digit, "api key", "access token" or "secret key" followed by a word of six characters or more, the word for "password" in the interface's languages diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index d65f21d9de..1cacaa9d7e 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -67,6 +67,13 @@ 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. */ +const SUGGEST_MAX_WORDS = 8; + /** * Words that say a number is an account, a card, a phone or a secret, in the * interface's languages where they differ ("Karte", "Telefon", "tarjeta"). @@ -85,7 +92,8 @@ function foldLine(text) { .normalize('NFKC') .replace(/\p{Cf}/gu, '') .replace(/[\u2018\u2019]/g, "'") - .replace(/(?![0-9])\p{Nd}/gu, '0'); + .replace(/(?![0-9])\p{Nd}/gu, '0') + .replace(/\s+/g, ' '); } /** A US ZIP+4 after a state's code or name, as an address writes it. */ @@ -122,21 +130,45 @@ function privacyReason(text) { return 'other'; // An email written around a filter: "john(at)gmail.com", // "john[at]gmail[dot]com", "john at gmail dot com". + // Also "john at gmail.com" and a "(dot)" or "[dot]" in any of them. 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\s+\p{L}{2,6}\b/iu.test(line) + /\b\S+\s+at\s+\S+\s+(?:dot|[([{<]\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( + line, + ) || + /\b[\p{L}\p{N}._%+-]+\s+at\s+[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*\.(?:com|net|org|edu|gov|mil|io|co|me|info|biz|app|dev|ai|[a-z]{2})\b/iu.test( + line, + ) ) return 'other'; // An IP address ("10.0.0.1"). if (/(? { + const bare = token.replace(/^[[(]+|[\]),.;]+$/g, '').replace(/%\w+$/, ''); + const colons = (bare.match(/:/g) || []).length; + return ( + /^[0-9a-f:.]+$/i.test(bare) && + colons >= 2 && + (bare.includes('::') || colons >= 5) + ); + }) + ) + return 'other'; + // A wallet's recovery phrase: 12, 15, 18, 21 or 24 words, all of three + // to eight letters in lower case ("abandon ability able …"), unless it + // starts as a request does ("show flights over texas …"). A line that + // long is never sent for suggestions anyway (see SUGGEST_MAX_WORDS). const words = line.trim().split(/\s+/); if ( [12, 15, 18, 21, 24].includes(words.length) && - new Set(words).size === words.length && - words.every((word) => /^[a-z]{3,8}$/.test(word)) + words.every((word) => /^[a-z]{3,8}$/.test(word)) && + !REQUEST_START.test(line) ) return 'other'; // A passphrase run together ("correcthorsebatterystaple"): a line that @@ -190,7 +222,7 @@ function privacyReason(text) { .replace(US_ZIP4, ' x ') .replace(/\b\d{5}-\d{3}\b/g, ' x ') .replace( - /〒\s?\d{3}-\d{4}|\b\d{3}-\d{4}(?=\s*[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}])|(?<=\p{L}{3,},?\s)\d{3}-\d{4}(?=\s*$|,)/gu, + /〒\s?\d{3}-\d{4}|\b\d{3}-\d{4}(?=\s*[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}])|(?<=[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]\s*)\d{3}-\d{4}\b/gu, ' x ', ) .replace(/#/g, ' x ') @@ -221,7 +253,12 @@ function privacyReason(text) { /\b(?:token|secret|api[ _-]?key|key|pass)\s*[:=]\s*\S/i.test(line) || // A number on a document or account after its label: "license ABC1234", // "passport X1234567", "plate 7ABC123", "member no. 12345". - /\b(?:licen[cs]e|plate|passport|member(?:ship)?|account|acct|policy|ticket|booking|confirmation|ref(?:erence)?)(?:\s+(?:no\.?|number|#|is))*\s*[:=#]?\s+(?=[a-z0-9-]*\d)(?=[a-z0-9-]*[a-z])[a-z0-9-]{4,}/i.test( + /\b(?:licen[cs]e|plate|passport|member(?:ship)?|account|acct|policy|ticket|booking|confirmation|ref(?:erence)?)(?:\s+(?:no\.?|number|#|is))*\s*[:=#]?\s+(?=[a-z0-9-]*\d)[a-z0-9-]{4,}/i.test( + line, + ) || + // An identity number after "ID" in capitals ("ID AB123"); "Id" and + // "id" are words. + /\bID(?:\s+(?:no\.?|number|#|is))*\s*[:=#]?\s+(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{4,}/.test( line, ) || /\b(?:my secret is|passphrase|mnemonic|seed phrase|recovery phrase)\b\s*[:=]?\s*\S/i.test( @@ -261,10 +298,21 @@ function privacyReason(text) { /** A value after "bearer" that is not a capitalised name ("Bearer Island"). */ function bearerToken(line) { - const match = /\bbearer\b\s*[:=#]?\s*(\S+)/i.exec(line); - return Boolean(match) && !/^\p{Lu}\p{Ll}+$/u.test(match[1]); + for (const match of line.matchAll(/\bbearer\b\s*[:=#]?\s*(\S+)/gi)) { + const value = match[1].replace(/[,.;:!?)]+$/, ''); + // A name: capitalised and short ("Bearer Island, Canada"), or a word + // a place's name is made of ("bearer island"). + if (/^\p{Lu}\p{Ll}{1,11}$/u.test(value) || PLACE_WORDS.test(value)) + continue; + return true; + } + return false; } +/** Words a place's name is made of, after a label word ("bearer island"). */ +const PLACE_WORDS = + /^(?:island|islands|isle|lake|creek|river|point|bay|mountain|mount|hill|hills|valley|station|road|street|lane|avenue|park|beach|falls|springs?|county|city|town|village)$/i; + /** * A code after a label that can only be a code, without a colon ("PIN * A7B2", "verification code ABCDEF", "otp 7GH2K"): holding a digit, or in @@ -275,11 +323,30 @@ function codeAfterLabel(line) { // Labels that only ever name a code take one in lower case too ("otp // abcdef", "cvv abc", "verification code abcdef"); a capitalised word // after them is a name ("OTP Bank", "MFA Boston"). + // After a label in lower case, any value is a code ("verification code + // Abc"); after one written as a name, only a value that is not one. const coded = - /\b(?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?\s+([a-z0-9][a-z0-9-]{2,})\s*[.!]?\s*$/i.exec( + /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,})(?:\s+(?:thanks|thank you|thx|please|pls|ok))?\s*[.!]?\s*$/i.exec( line, ); - if (coded && !/^\p{Lu}(?:\p{Ll}+|\p{Lu}+)$/u.test(coded[1])) return true; + if (coded) { + const [, label, value] = coded; + const labelIsName = /\p{Lu}/u.test(label); + if (!labelIsName) return true; + if (!/^\p{Lu}(?:\p{Ll}+|\p{Lu}+)$/u.test(value)) return true; + } + // A value in mixed case that is no name ("PIN aBcD", "gate code aBcD"). + const mixed = + /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,})\s*[.!]?\s*$/i.exec( + line, + ); + if ( + mixed && + /\p{Ll}/u.test(mixed[1]) && + /\p{Lu}/u.test(mixed[1]) && + !/^\p{Lu}\p{Ll}+$/u.test(mixed[1]) + ) + return true; const match = /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,})\s*[.!]?\s*$/i.exec( line, @@ -394,7 +461,14 @@ export function createPlaceSuggester({ const text = String(query ?? '') .trim() .slice(0, MAX_QUERY_CHARS); - if (!enabled || text.length < minPlaceChars(text) || mayBePrivate(text)) + // A line longer than a place's name is never sent: a pasted sentence + // or phrase is no place, and may be private in ways not read here. + if ( + !enabled || + text.length < minPlaceChars(text) || + text.split(/\s+/).length > SUGGEST_MAX_WORDS || + mayBePrivate(text) + ) return []; const language = (globalThis.document?.documentElement?.lang || 'en') .slice(0, 2) diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index c2a958d2fc..6bd93f558a 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -460,7 +460,13 @@ test('places that only looked private are looked up', () => { 'Akiak', 'Bearer Island', 'SSN Station', - 'Shibuya 150-0002', + 'Bearer Island, Canada', + 'bearer island', + 'Washington DC 20500-0003', + '東京都千代田区100-0001', + 'Security Code Plaza', + 'Idaho Falls', + 'meet at 12:30:45', 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch', 'OTP Bank', // A long request is not a recovery phrase. @@ -511,3 +517,47 @@ test('a house is named by its number and street in the order its country writes ['Mittenwald Au 3', 'Mittenwald Au 5'], ); }); + +test('codes, phones, tokens, emails and addresses in further shapes stay private', () => { + for (const line of [ + // A phone's three and four digits after a name, as a postcode can't be + // told from it ("Shibuya 150-0002" is refused for that). + 'Alice 555-0100', + 'Shibuya 150-0002', + `${Array(23).fill('abandon').join(' ')} art`, + 'Bearer Abcdefghijklmnopqrstuvwxyz', + 'Bearer Island bearer abcdef', + 'verification code Abc', + 'verification code ABC', + 'verification code abc thanks', + 'PIN aBcD', + 'gate code aBcD', + 'john at gmail.com', + 'john at gmail (dot) com', + 'john at gmail [dot] com', + 'john at gmail dot technology', + 'passport number 123456', + 'passport no. 123456', + 'ID AB123', + '::1', + 'fe80::1', + '2001:db8:0:0:0:0:2:1', + ]) + assert.equal(mayBePrivate(line), true, line); +}); + +test('a line longer than a place name is never sent for suggestions', async () => { + let sent = 0; + const service = createPlaceSuggester({ + endpoint: 'https://fixture.test/api/', + fetchImpl: async () => { + sent++; + return Response.json({ features: [] }); + }, + }); + assert.deepEqual( + await service.suggest('one two three four five six seven eight nine'), + [], + ); + assert.equal(sent, 0); +}); From 200c788ac1fbe83535b900d50b36747db39fbe6d Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:13:12 -0800 Subject: [PATCH 03/14] Let Idaho, questions and long place names through, and keep more tokens and codes private MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Boise ID 83702" names Idaho rather than an identity number. A long question for the assistant is no recovery phrase: a phrase holds none of the common words its list lacks ("the", "and", "are"). A long lower-case place name is no passphrase, an address of up to ten words is sent as the Omnibar reads it, and "mfa boston", "otp bank" and "security code plaza" are names. "Authorization: Bearer" and any value after "bearer" but a place word are tokens, and so are GitLab, Hugging Face and SendGrid keys and a code in a link. Door, alarm and lockbox numbers (not a zip or area code), a spaced UK National Insurance number, "my id is …", and emails spelled with "punto", "period", a spaced dot or letter by letter are private too. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 25 ++++-- src/search/placeSuggestions.js | 128 +++++++++++++++++++++------ src/search/placeSuggestions.test.mjs | 39 +++++++- 3 files changed, 155 insertions(+), 37 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index e22add909e..3c8fea39b4 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8026,11 +8026,13 @@ while the tab is hidden. A place search on its own runs through Location and shares its cancellation and errors, keeping the separate Location draft intact. -While typing, a short line (six words or fewer, no `?`, not a command, +While typing, a short line (six words or fewer, ten with a number in it +as an address has, no `?`, not a command, coordinates, a hex code, a callsign such as UAL2110 or N123AB, and nothing that may be private) is sent to Photon for place suggestions (the suggester itself never sends a line of -more than eight words): at most one request every 500 ms per tab, +more than eight words, or ten with a number): at most one request every +500 ms per tab, and none for a minute after a refusal. Photon is the keyless geocoder the place search already uses; a submitted search is not part of this spacing. A line that may be one name ("Satellite Beach") is looked up whole. While @@ -8087,7 +8089,8 @@ key", "access token" or "secret key" followed by a word of six characters or more, the word for "password" in the interface's languages (contraseña, Passwort, mot de passe, пароль…) followed by anything, or "pin" (also "pin code", "pin number", "pin is") followed by a digit; a word -starting `sk_`, `sk-`, `rk_`, `pk_live`, `ghp_` or a Slack token's `xoxb-` and the like (any case) or +starting `sk_`, `sk-`, `rk_`, `pk_live`, `ghp_`, `github_pat_`, `glpat-`, `hf_`, a SendGrid +`SG.` key or a Slack token's `xoxb-` and the like (any case) or `AIza` or `eyJ`, or an AWS key id (`AKIA` and twelve capitals or digits more; "Akiak" is a place); or a word that may be a password or key, with letters and digits mixed within one run (a number beside a word, as in "Yanino-1", "2-chōme" or @@ -8109,13 +8112,23 @@ to search it as a place on purpose ("Search … as a place anyway"), which runs the ordinary place search and its online services only when picked; a bare number, an email or handle, a password, key, code or IBAN gets none. A suggested house is named by its number and its street (or, without a -street, its locality) in the order its country writes them: "10 Downing +street, its locality, district or city) in the order its country writes them: "10 Downing Street", "Hauptstraße 12". A nine-digit number or a short phone number written with no such word still gets the row: only picking it sends anything. One-time and verification codes, OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, -recovery or seed phrases, "my secret is …" and an email spelled out ("john -at example dot com") are private too. Text that parses as coordinates or a +recovery or seed phrases (twelve to twenty-four short words with none of +the common words a phrase list lacks, such as "the", "and" or "are", so a +long question still goes to Ask GEV), "my secret is …", an email spelled +out ("john at example dot com", "punto com", or letter by letter), a door, +alarm or lockbox number ("code 4821"; "zip code 90210" and "area code 415" +are places), "Authorization: Bearer …", a code in a link (`?code=…`), a +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 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 1cacaa9d7e..075ab4d571 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -71,8 +71,43 @@ export function onlyNumbersLookPrivate(text) { 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. */ -const SUGGEST_MAX_WORDS = 8; +/** + * 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). + */ +const suggestMaxWords = (text) => (/\d/.test(text) ? 10 : 8); + +/** + * Common words no wallet's recovery phrase holds (they are not on the BIP39 + * list): a line with one is a sentence, however many short words it has. + */ +const NOT_SEED_WORDS = new Set([ + 'the', + 'and', + 'are', + 'for', + 'from', + 'with', + 'how', + 'why', + 'which', + '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). + */ +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; /** * Words that say a number is an account, a card, a phone or a secret, in the @@ -93,7 +128,8 @@ function foldLine(text) { .replace(/\p{Cf}/gu, '') .replace(/[\u2018\u2019]/g, "'") .replace(/(?![0-9])\p{Nd}/gu, '0') - .replace(/\s+/g, ' '); + .replace(/\s+/g, ' ') + .replace(IDAHO_BEFORE_ZIP, 'Idaho'); } /** A US ZIP+4 after a state's code or name, as an address writes it. */ @@ -131,15 +167,21 @@ function privacyReason(text) { // An email written around a filter: "john(at)gmail.com", // "john[at]gmail[dot]com", "john at gmail dot com". // Also "john at gmail.com" and a "(dot)" or "[dot]" in any of them. + // Spaced letter by letter ("j o h n @ g m a i l . c o m"). + if ( + /(?:^|\s)(?:\S\s){3,}@\s?(?:\S\s?){2,}/u.test(line) && + /[^@]@[\p{L}\p{N}-]+\.\p{L}{2,}/u.test(line.replace(/\s+/g, '')) + ) + 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|[([{<]\s*dot\s*[)\]}>])\s+\p{L}{2,24}\b/iu.test( + /\b\S+\s+at\s+\S+\s+(?:dot|punto|ponto|period|point|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( line, ) || - /\b[\p{L}\p{N}._%+-]+\s+at\s+[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*\.(?:com|net|org|edu|gov|mil|io|co|me|info|biz|app|dev|ai|[a-z]{2})\b/iu.test( + /\b[\p{L}\p{N}._%+-]+\s+at\s+[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*\s*\.\s*(?:com|net|org|edu|gov|mil|io|co|me|info|biz|app|dev|ai|[a-z]{2})\b/iu.test( line, ) ) @@ -160,23 +202,20 @@ function privacyReason(text) { }) ) return 'other'; - // A wallet's recovery phrase: 12, 15, 18, 21 or 24 words, all of three - // to eight letters in lower case ("abandon ability able …"), unless it - // starts as a request does ("show flights over texas …"). A line that - // long is never sent for suggestions anyway (see SUGGEST_MAX_WORDS). - const words = line.trim().split(/\s+/); + // A wallet's recovery phrase, whole or nearly ("abandon ability able + // …"): twelve to twenty-four words of three to eight letters, none a + // common word the phrase list lacks ("can you tell where the most …" is + // a question), and not starting as a request does. Too long to be sent + // for suggestions anyway, it is kept from the assistant too. + const words = line.trim().toLowerCase().split(/\s+/); if ( - [12, 15, 18, 21, 24].includes(words.length) && + words.length >= 12 && + words.length <= 24 && words.every((word) => /^[a-z]{3,8}$/.test(word)) && - !REQUEST_START.test(line) + !words.some((word) => NOT_SEED_WORDS.has(word)) && + !REQUEST_START.test(words[0]) ) return 'other'; - // A passphrase run together ("correcthorsebatterystaple"): a line that - // is one word of twenty letters or more, all lower case. A long place - // name is written with its capital ("Llanfairpwllgwyngyll"), and a long - // word inside a name ("… selskokhozyaystvennoy opytnoy stantsii") has - // others beside it. - if (words.length === 1 && /^[a-z]{20,}$/.test(words[0])) return 'other'; // Coordinates and grid references are a spot, not a number to keep: only // text the place search itself reads as coordinates, as typed ("١٢٣٤, // ٥٦٧٨" folded would read as a spot, but is not one). @@ -275,7 +314,27 @@ function privacyReason(text) { /\b(?:pin|otp|2fa|mfa|cvv|cvc|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)\s*(?:[:=#]|\s[-–—]\s|-)\s*[a-z0-9]/i.test( line, ) || - codeAfterLabel(line) + codeAfterLabel(line) || + // A door, alarm or lockbox number ("code 4821", "garage code 4821", + // "the code to my door is 4821"). + // A postcode, dialling code or airport code is not one ("zip code + // 90210", "area code 415"). + /\b(? token.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, '')) .some( (token) => - /^(?:sk[-_]|rk_|pk_live|ghp_|xox[abposr]-)/i.test(token) || + /^(?:sk[-_]|rk_|pk_live|ghp_|gho_|ghu_|ghs_|github_pat_|glpat-|hf_|xox[abposr]-)/i.test( + token, + ) || + /^SG\.[\w-]{8,}\.[\w-]{8,}$/.test(token) || /^(?:AIza|eyJ)/.test(token) || /^AKIA[0-9A-Z]{12,}$/.test(token) || mayBeSecret(token), @@ -296,14 +358,15 @@ function privacyReason(text) { return longNumber ? 'number' : null; } -/** A value after "bearer" that is not a capitalised name ("Bearer Island"). */ +/** + * A value after "bearer" that is not a word a place's name is made of + * ("Bearer Island"); after "Authorization:" any value is a token. + */ function bearerToken(line) { + if (/\bauthori[sz]ation\s*:\s*bearer\b\s*\S/i.test(line)) return true; for (const match of line.matchAll(/\bbearer\b\s*[:=#]?\s*(\S+)/gi)) { const value = match[1].replace(/[,.;:!?)]+$/, ''); - // A name: capitalised and short ("Bearer Island, Canada"), or a word - // a place's name is made of ("bearer island"). - if (/^\p{Lu}\p{Ll}{1,11}$/u.test(value) || PLACE_WORDS.test(value)) - continue; + if (PLACE_WORDS.test(value)) continue; return true; } return false; @@ -311,7 +374,7 @@ function bearerToken(line) { /** Words a place's name is made of, after a label word ("bearer island"). */ const PLACE_WORDS = - /^(?:island|islands|isle|lake|creek|river|point|bay|mountain|mount|hill|hills|valley|station|road|street|lane|avenue|park|beach|falls|springs?|county|city|town|village)$/i; + /^(?:island|islands|isle|lake|creek|river|point|bay|mountain|mount|hill|hills|valley|station|road|street|lane|avenue|park|beach|falls|springs?|county|city|town|village|plaza|square|mall|center|centre|tower|building|court|bank)$/i; /** * A code after a label that can only be a code, without a colon ("PIN @@ -332,8 +395,15 @@ function codeAfterLabel(line) { if (coded) { const [, label, value] = coded; const labelIsName = /\p{Lu}/u.test(label); - if (!labelIsName) return true; - if (!/^\p{Lu}(?:\p{Ll}+|\p{Lu}+)$/u.test(value)) return true; + // A word a place's name is made of is no code ("security code plaza", + // "otp bank"); after the short labels a code in letters is written in + // capitals ("otp ABCDEF"), so a lower-case word is a name ("mfa + // boston"). + const shortLabel = /^(?:otp|2fa|mfa)\b/i.test(label); + const named = + PLACE_WORDS.test(value) || (shortLabel && /^\p{Ll}+$/u.test(value)); + if (!labelIsName && !named) return true; + if (labelIsName && !/^\p{Lu}(?:\p{Ll}+|\p{Lu}+)$/u.test(value)) return true; } // A value in mixed case that is no name ("PIN aBcD", "gate code aBcD"). const mixed = @@ -466,7 +536,7 @@ export function createPlaceSuggester({ if ( !enabled || text.length < minPlaceChars(text) || - text.split(/\s+/).length > SUGGEST_MAX_WORDS || + text.split(/\s+/).length > suggestMaxWords(text) || mayBePrivate(text) ) return []; diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index 6bd93f558a..e7c66c48f1 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -437,14 +437,31 @@ test('spelled-out emails, addresses, phrases, codes and short phone numbers stay 'john at gmail dot de', '10.0.0.1', 'abandon ability able about above absent absorb abstract absurd abuse access accident', - 'correcthorsebatterystaple', + 'Abandon ability able about above absent absorb abstract absurd abuse access accident acid', 'license ABC1234', 'passport X1234567', 'plate 7ABC123', - 'otp abcdef', + 'otp ABCDEF', 'verification code abcdef', 'cvv abc', 'Bearer abcdef', + 'Bearer Abcdefgh', + 'Authorization: Bearer Xyz', + 'glpat-abcdef123456', + 'hf_abcdefghijk', + 'SG.abcdefghij.klmnopqrstuv', + 'https://x.com/?code=abcdef', + 'code 4821', + 'garage code 4821', + 'lockbox 4821', + 'the code to my door is 4821', + 'AB 12 34 56 C', + 'my id is AB12345', + 'My ID 12345', + 'john at gmail .com', + 'john at gmail punto com', + 'john.doe at example period com', + 'j o h n @ g m a i l . c o m', 'ssn 123', 'Jo 12345-6789', 'Joe 1234 12345 thanks', @@ -468,6 +485,19 @@ test('places that only looked private are looked up', () => { 'Idaho Falls', 'meet at 12:30:45', 'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch', + 'llanfairpwllgwyngyll', + 'Boise ID 83702', + 'Boise, ID 83702', + 'Hayden ID 83835-1234', + 'mfa boston', + 'otp bank', + 'security code plaza', + 'zip code 90210', + 'area code 415', + 'Settipalle @ K.Bandarlapalle', + // 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', 'OTP Bank', // A long request is not a recovery phrase. 'show flights over texas near austin with altitude above thirty thousand feet please', @@ -560,4 +590,9 @@ test('a line longer than a place name is never sent for suggestions', async () = [], ); assert.equal(sent, 0); + // An address has more words: as many as the Omnibar reads as a place. + await service.suggest('350 Fifth Avenue, New York, NY 10118, United States'); + assert.equal(sent, 1); + await service.suggest('1 2 3 4 5 6 7 8 9 10 11'); + assert.equal(sent, 1); }); From 2a4079e9f8cc30e0badfeb8be4945a5f85b3a04a Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:21:32 -0800 Subject: [PATCH 04/14] 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', From d15c69a8aec3809718bda32825dc0aebadb615e1 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 17:21:40 -0800 Subject: [PATCH 05/14] Add the changelog entry for the place privacy fixes Co-authored-by: Manjunath Paparaju --- changelog.d/1830-place-privacy.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changelog.d/1830-place-privacy.md diff --git a/changelog.d/1830-place-privacy.md b/changelog.d/1830-place-privacy.md new file mode 100644 index 0000000000..ebb9aea283 --- /dev/null +++ b/changelog.d/1830-place-privacy.md @@ -0,0 +1,7 @@ +- More private text typed into the Omnibar or Location search stays off the + place service: emails spelled out or spaced, IP addresses, wallet recovery + phrases, door, alarm and lockbox numbers, codes after their labels, + document and ID numbers, SSNs, more API token shapes and codes in links. + More real places get through: "Boise ID 83702", house numbers in the + order their country writes them, addresses of up to ten words, and long + questions for Ask GEV (manjunath22466, samehkhamis, #1830). From 2487500927510aa45fc6736a4ca0faea0c1ac825 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 18:17:22 -0800 Subject: [PATCH 06/14] Read recovery phrases against the BIP39 list, and fix four more privacy readings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A recovery phrase is now twelve to twenty-four words that are all on the BIP39 English list, so a long request ("show every plane over london then …") reaches Ask GEV while a phrase holding "find" or "please" is still caught. A time in brackets is no IPv6 address (only a bracketed host after "//" is), "St 123456 A" is no National Insurance number (spaced in pairs or not at all), "my, ID 12345" keeps its owner, a partial "ssn 1" stays private while typed, any CVV value is private, and a code followed by "thanks" or "now" is still a code. Idaho's reading no longer slows down on very long lines. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 6 +- scripts/format-scope.json | 1 + scripts/package-boundaries.json | 3 +- src/search/bip39Words.js | 210 +++++++++++++++++++++++++++ src/search/placeSuggestions.js | 71 ++++----- src/search/placeSuggestions.test.mjs | 9 ++ 6 files changed, 252 insertions(+), 48 deletions(-) create mode 100644 src/search/bip39Words.js diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 3ba93c795a..89be93a338 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8114,9 +8114,9 @@ Street", "Hauptstraße 12". A nine-digit number or a short phone number written with no such word still gets the row: only picking it sends anything. One-time and verification codes, OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, -recovery or seed phrases (twelve to twenty-four short words with none of -the common words a phrase list lacks, such as "the", "and" or "are", so a -long question still goes to Ask GEV), "my secret is …", an email spelled +recovery or seed phrases (twelve to twenty-four words, every one on the +BIP39 English list in `src/search/bip39Words.js`, so a long question or +request still goes to Ask GEV), "my secret is …", an email spelled out ("john at example dot com", "punto com", or letter by letter), a door, alarm or lockbox number ("code 4821"; "zip code 90210" and "area code 415" are places), "Authorization: Bearer …", a code in a link (`?code=…`), a diff --git a/scripts/format-scope.json b/scripts/format-scope.json index 78f3edbf24..b707873ea8 100644 --- a/scripts/format-scope.json +++ b/scripts/format-scope.json @@ -1592,6 +1592,7 @@ "src/data/wikidataCities.js", "src/data/wikidataCities.test.mjs", "scripts/build-wikidata-cities.mjs", + "src/search/bip39Words.js", "src/search/placeSuggestions.test.mjs", "scripts/wikidataPlaceTiles.mjs", "src/tooling/wikidataPlaceTiles.test.mjs", diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json index 8910282ebc..e5914d9fdc 100644 --- a/scripts/package-boundaries.json +++ b/scripts/package-boundaries.json @@ -307,7 +307,8 @@ "src/ui/omnibarRows.js", "src/search/gridReference.js", "src/search/coordinateParser.js", - "src/search/placeSuggestions.js" + "src/search/placeSuggestions.js", + "src/search/bip39Words.js" ], "external": ["vue", "pinia", "vue-i18n"] }, diff --git a/src/search/bip39Words.js b/src/search/bip39Words.js new file mode 100644 index 0000000000..0c8fa29f63 --- /dev/null +++ b/src/search/bip39Words.js @@ -0,0 +1,210 @@ +/** + * @module search/bip39Words + * @description The 2048 words of the BIP39 English list, from which wallet + * recovery phrases are made (github.com/bitcoin/bips, bip-0039/english.txt). + * Only read to keep a typed phrase from leaving the browser. + */ + +const WORDS = ` +abandon ability able about above absent absorb abstract absurd abuse +access accident account accuse achieve acid acoustic acquire across +act action actor actress actual adapt add addict address adjust admit +adult advance advice aerobic affair afford afraid again age agent +agree ahead aim air airport aisle alarm album alcohol alert alien all +alley allow almost alone alpha already also alter always amateur +amazing among amount amused analyst anchor ancient anger angle angry +animal ankle announce annual another answer antenna antique anxiety +any apart apology appear apple approve april arch arctic area arena +argue arm armed armor army around arrange arrest arrive arrow art +artefact artist artwork ask aspect assault asset assist assume asthma +athlete atom attack attend attitude attract auction audit august aunt +author auto autumn average avocado avoid awake aware away awesome +awful awkward axis baby bachelor bacon badge bag balance balcony ball +bamboo banana banner bar barely bargain barrel base basic basket +battle beach bean beauty because become beef before begin behave +behind believe below belt bench benefit best betray better between +beyond bicycle bid bike bind biology bird birth bitter black blade +blame blanket blast bleak bless blind blood blossom blouse blue blur +blush board boat body boil bomb bone bonus book boost border boring +borrow boss bottom bounce box boy bracket brain brand brass brave +bread breeze brick bridge brief bright bring brisk broccoli broken +bronze broom brother brown brush bubble buddy budget buffalo build +bulb bulk bullet bundle bunker burden burger burst bus business busy +butter buyer buzz cabbage cabin cable cactus cage cake call calm +camera camp can canal cancel candy cannon canoe canvas canyon capable +capital captain car carbon card cargo carpet carry cart case cash +casino castle casual cat catalog catch category cattle caught cause +caution cave ceiling celery cement census century cereal certain chair +chalk champion change chaos chapter charge chase chat cheap check +cheese chef cherry chest chicken chief child chimney choice choose +chronic chuckle chunk churn cigar cinnamon circle citizen city civil +claim clap clarify claw clay clean clerk clever click client cliff +climb clinic clip clock clog close cloth cloud clown club clump +cluster clutch coach coast coconut code coffee coil coin collect color +column combine come comfort comic common company concert conduct +confirm congress connect consider control convince cook cool copper +copy coral core corn correct cost cotton couch country couple course +cousin cover coyote crack cradle craft cram crane crash crater crawl +crazy cream credit creek crew cricket crime crisp critic crop cross +crouch crowd crucial cruel cruise crumble crunch crush cry crystal +cube culture cup cupboard curious current curtain curve cushion custom +cute cycle dad damage damp dance danger daring dash daughter dawn day +deal debate debris decade december decide decline decorate decrease +deer defense define defy degree delay deliver demand demise denial +dentist deny depart depend deposit depth deputy derive describe desert +design desk despair destroy detail detect develop device devote +diagram dial diamond diary dice diesel diet differ digital dignity +dilemma dinner dinosaur direct dirt disagree discover disease dish +dismiss disorder display distance divert divide divorce dizzy doctor +document dog doll dolphin domain donate donkey donor door dose double +dove draft dragon drama drastic draw dream dress drift drill drink +drip drive drop drum dry duck dumb dune during dust dutch duty dwarf +dynamic eager eagle early earn earth easily east easy echo ecology +economy edge edit educate effort egg eight either elbow elder electric +elegant element elephant elevator elite else embark embody embrace +emerge emotion employ empower empty enable enact end endless endorse +enemy energy enforce engage engine enhance enjoy enlist enough enrich +enroll ensure enter entire entry envelope episode equal equip era +erase erode erosion error erupt escape essay essence estate eternal +ethics evidence evil evoke evolve exact example excess exchange excite +exclude excuse execute exercise exhaust exhibit exile exist exit +exotic expand expect expire explain expose express extend extra eye +eyebrow fabric face faculty fade faint faith fall false fame family +famous fan fancy fantasy farm fashion fat fatal father fatigue fault +favorite feature february federal fee feed feel female fence festival +fetch fever few fiber fiction field figure file film filter final find +fine finger finish fire firm first fiscal fish fit fitness fix flag +flame flash flat flavor flee flight flip float flock floor flower +fluid flush fly foam focus fog foil fold follow food foot force forest +forget fork fortune forum forward fossil foster found fox fragile +frame frequent fresh friend fringe frog front frost frown frozen fruit +fuel fun funny furnace fury future gadget gain galaxy gallery game gap +garage garbage garden garlic garment gas gasp gate gather gauge gaze +general genius genre gentle genuine gesture ghost giant gift giggle +ginger giraffe girl give glad glance glare glass glide glimpse globe +gloom glory glove glow glue goat goddess gold good goose gorilla +gospel gossip govern gown grab grace grain grant grape grass gravity +great green grid grief grit grocery group grow grunt guard guess guide +guilt guitar gun gym habit hair half hammer hamster hand happy harbor +hard harsh harvest hat have hawk hazard head health heart heavy +hedgehog height hello helmet help hen hero hidden high hill hint hip +hire history hobby hockey hold hole holiday hollow home honey hood +hope horn horror horse hospital host hotel hour hover hub huge human +humble humor hundred hungry hunt hurdle hurry hurt husband hybrid ice +icon idea identify idle ignore ill illegal illness image imitate +immense immune impact impose improve impulse inch include income +increase index indicate indoor industry infant inflict inform inhale +inherit initial inject injury inmate inner innocent input inquiry +insane insect inside inspire install intact interest into invest +invite involve iron island isolate issue item ivory jacket jaguar jar +jazz jealous jeans jelly jewel job join joke journey joy judge juice +jump jungle junior junk just kangaroo keen keep ketchup key kick kid +kidney kind kingdom kiss kit kitchen kite kitten kiwi knee knife knock +know lab label labor ladder lady lake lamp language laptop large later +latin laugh laundry lava law lawn lawsuit layer lazy leader leaf learn +leave lecture left leg legal legend leisure lemon lend length lens +leopard lesson letter level liar liberty library license life lift +light like limb limit link lion liquid list little live lizard load +loan lobster local lock logic lonely long loop lottery loud lounge +love loyal lucky luggage lumber lunar lunch luxury lyrics machine mad +magic magnet maid mail main major make mammal man manage mandate mango +mansion manual maple marble march margin marine market marriage mask +mass master match material math matrix matter maximum maze meadow mean +measure meat mechanic medal media melody melt member memory mention +menu mercy merge merit merry mesh message metal method middle midnight +milk million mimic mind minimum minor minute miracle mirror misery +miss mistake mix mixed mixture mobile model modify mom moment monitor +monkey monster month moon moral more morning mosquito mother motion +motor mountain mouse move movie much muffin mule multiply muscle +museum mushroom music must mutual myself mystery myth naive name +napkin narrow nasty nation nature near neck need negative neglect +neither nephew nerve nest net network neutral never news next nice +night noble noise nominee noodle normal north nose notable note +nothing notice novel now nuclear number nurse nut oak obey object +oblige obscure observe obtain obvious occur ocean october odor off +offer office often oil okay old olive olympic omit once one onion +online only open opera opinion oppose option orange orbit orchard +order ordinary organ orient original orphan ostrich other outdoor +outer output outside oval oven over own owner oxygen oyster ozone pact +paddle page pair palace palm panda panel panic panther paper parade +parent park parrot party pass patch path patient patrol pattern pause +pave payment peace peanut pear peasant pelican pen penalty pencil +people pepper perfect permit person pet phone photo phrase physical +piano picnic picture piece pig pigeon pill pilot pink pioneer pipe +pistol pitch pizza place planet plastic plate play please pledge pluck +plug plunge poem poet point polar pole police pond pony pool popular +portion position possible post potato pottery poverty powder power +practice praise predict prefer prepare present pretty prevent price +pride primary print priority prison private prize problem process +produce profit program project promote proof property prosper protect +proud provide public pudding pull pulp pulse pumpkin punch pupil puppy +purchase purity purpose purse push put puzzle pyramid quality quantum +quarter question quick quit quiz quote rabbit raccoon race rack radar +radio rail rain raise rally ramp ranch random range rapid rare rate +rather raven raw razor ready real reason rebel rebuild recall receive +recipe record recycle reduce reflect reform refuse region regret +regular reject relax release relief rely remain remember remind remove +render renew rent reopen repair repeat replace report require rescue +resemble resist resource response result retire retreat return reunion +reveal review reward rhythm rib ribbon rice rich ride ridge rifle +right rigid ring riot ripple risk ritual rival river road roast robot +robust rocket romance roof rookie room rose rotate rough round route +royal rubber rude rug rule run runway rural sad saddle sadness safe +sail salad salmon salon salt salute same sample sand satisfy satoshi +sauce sausage save say scale scan scare scatter scene scheme school +science scissors scorpion scout scrap screen script scrub sea search +season seat second secret section security seed seek segment select +sell seminar senior sense sentence series service session settle setup +seven shadow shaft shallow share shed shell sheriff shield shift shine +ship shiver shock shoe shoot shop short shoulder shove shrimp shrug +shuffle shy sibling sick side siege sight sign silent silk silly +silver similar simple since sing siren sister situate six size skate +sketch ski skill skin skirt skull slab slam sleep slender slice slide +slight slim slogan slot slow slush small smart smile smoke smooth +snack snake snap sniff snow soap soccer social sock soda soft solar +soldier solid solution solve someone song soon sorry sort soul sound +soup source south space spare spatial spawn speak special speed spell +spend sphere spice spider spike spin spirit split spoil sponsor spoon +sport spot spray spread spring spy square squeeze squirrel stable +stadium staff stage stairs stamp stand start state stay steak steel +stem step stereo stick still sting stock stomach stone stool story +stove strategy street strike strong struggle student stuff stumble +style subject submit subway success such sudden suffer sugar suggest +suit summer sun sunny sunset super supply supreme sure surface surge +surprise surround survey suspect sustain swallow swamp swap swarm +swear sweet swift swim swing switch sword symbol symptom syrup system +table tackle tag tail talent talk tank tape target task taste tattoo +taxi teach team tell ten tenant tennis tent term test text thank that +theme then theory there they thing this thought three thrive throw +thumb thunder ticket tide tiger tilt timber time tiny tip tired tissue +title toast tobacco today toddler toe together toilet token tomato +tomorrow tone tongue tonight tool tooth top topic topple torch tornado +tortoise toss total tourist toward tower town toy track trade traffic +tragic train transfer trap trash travel tray treat tree trend trial +tribe trick trigger trim trip trophy trouble truck true truly trumpet +trust truth try tube tuition tumble tuna tunnel turkey turn turtle +twelve twenty twice twin twist two type typical ugly umbrella unable +unaware uncle uncover under undo unfair unfold unhappy uniform unique +unit universe unknown unlock until unusual unveil update upgrade +uphold upon upper upset urban urge usage use used useful useless usual +utility vacant vacuum vague valid valley valve van vanish vapor +various vast vault vehicle velvet vendor venture venue verb verify +version very vessel veteran viable vibrant vicious victory video view +village vintage violin virtual virus visa visit visual vital vivid +vocal voice void volcano volume vote voyage wage wagon wait walk wall +walnut want warfare warm warrior wash wasp waste water wave way wealth +weapon wear weasel weather web wedding weekend weird welcome west wet +whale what wheat wheel when where whip whisper wide width wife wild +will win window wine wing wink winner winter wire wisdom wise wish +witness wolf woman wonder wood wool word work world worry worth wrap +wreck wrestle wrist write wrong yard year yellow you young youth zebra +zero zone zoo +`; + +let words = null; + +/** Whether `word` (lower case) is on the list. */ +export function isBip39Word(word) { + words ??= new Set(WORDS.split(/\s+/).filter(Boolean)); + return words.has(word); +} diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index c0389d817d..6b3803ec93 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -1,3 +1,4 @@ +import { isBip39Word } from './bip39Words.js'; import { normalizePhotonFeature, photonSearchUrl } from '../keylessGeocoder.js'; import { parseCoordinateQuery } from './coordinateParser.js'; import { @@ -73,35 +74,13 @@ export function onlyNumbersLookPrivate(text) { */ const suggestMaxWords = (text) => (/\d/.test(text) ? 10 : 8); -/** - * Common words no wallet's recovery phrase holds (they are not on the BIP39 - * list): a line with one is a sentence, however many short words it has. - */ -const NOT_SEED_WORDS = new Set([ - 'the', - 'and', - 'are', - 'for', - 'from', - 'with', - 'how', - 'why', - 'which', - 'would', - 'could', - 'should', - 'does', - 'was', - 'were', - 'flights', -]); - /** * "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+)(,?\s)ID(?=\.?,?\s+\d{5}(?:-\d{4})?(?!\S))/gu; +const IDAHO_BEFORE_ZIP = + /(? - ID_OWNERS.test(word) ? whole : `${word}${gap}Idaho`, + ID_OWNERS.test(word.replace(/\p{P}+$/u, '')) + ? whole + : `${word}${gap}Idaho`, ); } @@ -184,8 +165,12 @@ 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 IPv6 host in a link ("https://[::1]/"), not a time in brackets + // ("[12:30:00]"). + for (const [, host] of line.matchAll(/\/\/\[([0-9a-f:.%\w]+)\]/gi)) { + const colons = (host.match(/:/g) || []).length; + if (colons >= 2 && (host.includes('::') || colons >= 5)) 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)) - ) + if (words.length >= 12 && words.length <= 24 && words.every(isBip39Word)) return 'other'; // Coordinates and grid references are a spot, not a number to keep: only // text the place search itself reads as coordinates, as typed ("١٢٣٤, @@ -277,7 +256,9 @@ function privacyReason(text) { // but a capitalised name is a token, and a social security number has // digits. bearerToken(line) || - /\bssn\b(?:\s+(?:is|no\.?|number|#))*\s*[:=#]?\s*[\dx*]{3}/i.test(line) || + /\bssn\b(?:\s+(?:is|no\.?|number|#))*\s*[:=#]?\s*(?:\d|[x*]{2})/i.test( + line, + ) || // The word for "password" in the interface's languages. // A whole word only: "Sachsenhausen" holds "senha" but is a place. /(? Date: Wed, 18 Nov 2026 18:37:36 -0800 Subject: [PATCH 07/14] Withhold an SSN's last four, a code before ", thanks" and a recovery phrase written with commas or numbers "ssn ending 1234" and "ssn last four 1234" are private again, as before this change; a code may be followed by a comma, "cheers", "thanks a lot" or more than one "!"; a recovery phrase is twelve BIP39 words in a row, so commas, numbering, a closing period or "my seed is" before it no longer hide it. The spelled-out email patterns start only at a word, which keeps long inputs fast. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 11 ++++---- src/search/placeSuggestions.js | 38 +++++++++++++++++----------- src/search/placeSuggestions.test.mjs | 20 +++++++++++++++ 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 89be93a338..af4bd7243f 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8070,14 +8070,15 @@ digits and ten more letters or digits (an IBAN's shape); "password", "passcode", "passwd", "pw" or "pwd" followed by anything, "bearer" followed by anything but a short capitalised name or a place word such as island or lake ("Bearer Island", "bearer island" are places), -"ssn" followed by a digit ("SSN Station" is a place), "token", "secret", +"ssn" followed by a digit, also after "ending", "ends in" or "last four" +("SSN Station" is a place), "token", "secret", "api key", "key" or "pass" followed by ":" or "=", a licence, plate, passport, membership, account, policy, ticket, booking, confirmation or reference number with a digit after its label ("license ABC1234", "passport no. 123456"), "ID" in capitals followed by a number ("ID AB123"), "otp", "2fa", "mfa", "cvv", "cvc" or a verification, one-time, security, auth or login code followed by a code (any value after a label -in lower case, "verification code Abc", also before "thanks"; after a label +in lower case, "verification code Abc", also before "thanks", ", thanks", "cheers" or "thanks a lot"; after a label written as a name, any value that is not one: "OTP Bank" and "Security Code Plaza" are places), a "pin" or door, access, gate, alarm or entry code followed by a value in mixed case ("PIN aBcD"), a @@ -8114,9 +8115,9 @@ Street", "Hauptstraße 12". A nine-digit number or a short phone number written with no such word still gets the row: only picking it sends anything. One-time and verification codes, OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, -recovery or seed phrases (twelve to twenty-four words, every one on the -BIP39 English list in `src/search/bip39Words.js`, so a long question or -request still goes to Ask GEV), "my secret is …", an email spelled +recovery or seed phrases (twelve words in a row on the BIP39 English list +in `src/search/bip39Words.js`, also with commas, numbered or after "my seed +is", so a long question or request still goes to Ask GEV), "my secret is …", an email spelled out ("john at example dot com", "punto com", or letter by letter), a door, alarm or lockbox number ("code 4821"; "zip code 90210" and "area code 415" are places), "Authorization: Bearer …", a code in a link (`?code=…`), a diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index 6b3803ec93..5ad854a31d 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -154,13 +154,13 @@ 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|punkt|[([{<]\s*dot\s*[)\]}>])\s+\p{L}{2,24}\b/iu.test( + /(?])\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( + /(?]\s*\p{L}{2,24}\b/iu.test( line, ) || - /\b[\p{L}\p{N}._%+-]+\s+at\s+[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*\s*\.\s*(?:com|net|org|edu|gov|mil|io|co|me|info|biz|app|dev|ai|[a-z]{2})\b/iu.test( + /(?= 12 && words.length <= 24 && words.every(isBip39Word)) - return 'other'; + // A wallet's recovery phrase ("abandon ability able …"): twelve words in + // a row on the BIP39 list ("can you tell where the most …" is a + // question). Too long to be sent for suggestions anyway, it is kept from + // the assistant too. + // Written with commas, numbered ("1. abandon 2. ability") or after a few + // words ("my seed is …"): twelve of the list's words in a row. + let run = 0; + for (const token of line.toLowerCase().split(/[\s,;]+/)) { + const word = token.replace(/^\d+[.)]?/, '').replace(/[^a-z]+$/, ''); + if (!word && token) continue; + run = isBip39Word(word) ? run + 1 : 0; + if (run >= 12) return 'other'; + } // Coordinates and grid references are a spot, not a number to keep: only // text the place search itself reads as coordinates, as typed ("١٢٣٤, // ٥٦٧٨" folded would read as a spot, but is not one). @@ -256,7 +262,7 @@ function privacyReason(text) { // but a capitalised name is a token, and a social security number has // digits. bearerToken(line) || - /\bssn\b(?:\s+(?:is|no\.?|number|#))*\s*[:=#]?\s*(?:\d|[x*]{2})/i.test( + /\bssn\b(?:\s+(?:is|are|no\.?|number|#|ending|ends?|in|with|last|four|4|digits))*\s*[:=#]?\s*(?:\d|[x*]{2})/i.test( line, ) || // The word for "password" in the interface's languages. @@ -284,7 +290,9 @@ function privacyReason(text) { line, ) || // An email spelled out to slip past a filter: "john at example dot com". - /\b\S+\s+at\s+\S+\s+dot\s+(?:com|net|org|edu|gov|io|co)\b/i.test(line) || + /(? { + for (const unit of ['a-', 'a.', '1-', 'a ', '//[a:']) { + const started = performance.now(); + mayBePrivate(unit.repeat(10000)); + assert.ok(performance.now() - started < 1000, unit); + } +}); From f75f42d3cab4e4915f33533dad65a59746d795f3 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 19:13:04 -0800 Subject: [PATCH 08/14] Read lists of places as places, not recovery phrases, and keep code tails fast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Twelve BIP39 words in a row with three words for places or things on a map ("coffee, bar, hotel, museum, park …") are a list, not a phrase; a random phrase has three of them about once in two hundred. A code's value and the courtesy word after it no longer overlap, and trailing punctuation is trimmed from a word's end only, so a long run of hyphens is read at once. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 4 ++- src/search/placeSuggestions.js | 47 +++++++++++++++++++++++----- src/search/placeSuggestions.test.mjs | 14 +++++++-- 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index af4bd7243f..573cb130ff 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8117,7 +8117,9 @@ still gets the row: only picking it sends anything. One-time and verification co OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, recovery or seed phrases (twelve words in a row on the BIP39 English list in `src/search/bip39Words.js`, also with commas, numbered or after "my seed -is", so a long question or request still goes to Ask GEV), "my secret is …", an email spelled +is", so a long question or request still goes to Ask GEV; twelve with three +words for places or things on a map, such as "park", "beach" or "airport", +are a list of places), "my secret is …", an email spelled out ("john at example dot com", "punto com", or letter by letter), a door, alarm or lockbox number ("code 4821"; "zip code 90210" and "area code 415" are places), "Authorization: Bearer …", a code in a link (`?code=…`), a diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index 5ad854a31d..e3f3e1c938 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -15,6 +15,23 @@ export const isCjk = (text) => CJK.test(String(text || '')); /** The fewest characters a place name is looked up from. */ export const minPlaceChars = (text) => (isCjk(text) ? 2 : 3); +/** + * Words on the BIP39 list that name places and things on a map, for telling + * a list of places from a recovery phrase. + */ +const MAP_WORDS = new Set( + ( + 'airport bar beach bike boat bridge bus cafe car castle city coast coffee ' + + 'country desert east elevator ferry fire flight forest garden harbor ' + + 'hospital hotel house island lake market moon mountain museum north ' + + 'ocean office park planet pizza rain river road rocket satellite school ' + + 'sea ship shop snow south space station storm street sun ' + + 'swim taxi tower town traffic train truck tunnel valley village ' + + 'weather west wind world zoo canyon church stadium bank restaurant ' + + 'map area today tomorrow near' + ).split(' '), +); + /** * Text that may hold something private, which is never looked up, offered * as a place or sent anywhere: @@ -192,13 +209,25 @@ function privacyReason(text) { // question). Too long to be sent for suggestions anyway, it is kept from // the assistant too. // Written with commas, numbered ("1. abandon 2. ability") or after a few - // words ("my seed is …"): twelve of the list's words in a row. + // words ("my seed is …"): twelve of the list's words in a row. The list + // has many words for places and things on a map, and a phrase is drawn at + // random from all of it: twelve with three of those ("coffee, bar, + // hotel, museum, park …") is a list of places. let run = 0; + let mapWords = 0; for (const token of line.toLowerCase().split(/[\s,;]+/)) { - const word = token.replace(/^\d+[.)]?/, '').replace(/[^a-z]+$/, ''); + const word = token + .replace(/^\d+[.)]?/, '') + .replace(/(?<=[a-z])[^a-z]+$/, ''); if (!word && token) continue; - run = isBip39Word(word) ? run + 1 : 0; - if (run >= 12) return 'other'; + if (!isBip39Word(word)) { + run = 0; + mapWords = 0; + continue; + } + run += 1; + if (MAP_WORDS.has(word)) mapWords += 1; + if (run >= 12 && mapWords < 3) return 'other'; } // Coordinates and grid references are a spot, not a number to keep: only // text the place search itself reads as coordinates, as typed ("١٢٣٤, @@ -331,7 +360,9 @@ function privacyReason(text) { .split(/\s+/) // A key in quotes or brackets ("\"sk-…\"") and a postcode before a // comma ("SW1A2AA,") are read without them. - .map((token) => token.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, '')) + .map((token) => + token.replace(/^[^\p{L}\p{N}]+|(?<=[\p{L}\p{N}])[^\p{L}\p{N}]+$/gu, ''), + ) .some( (token) => /^(?:sk[-_]|rk_|pk_live|ghp_|gho_|ghu_|ghs_|github_pat_|glpat-|hf_|xox[abposr]-)/i.test( @@ -379,7 +410,7 @@ function codeAfterLabel(line) { // After a label in lower case, any value is a code ("verification code // Abc"); after one written as a name, only a value that is not one. const coded = - /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,})(?:[\s,;-]+(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,63})(?:(?:\s*[,;]\s*|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if (coded) { @@ -406,7 +437,7 @@ function codeAfterLabel(line) { } // A value in mixed case that is no name ("PIN aBcD", "gate code aBcD"). const mixed = - /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,})(?:[\s,;-]+(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,64})(?:(?:\s*[,;]\s*|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if ( @@ -417,7 +448,7 @@ function codeAfterLabel(line) { ) return true; const match = - /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,})(?:[\s,;-]+(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,63})(?:(?:\s*[,;]\s*|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if (!match) return false; diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index d20411f32d..b6f17b0bd6 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -539,6 +539,10 @@ test('places that only looked private are looked up', () => { 'meet at West Point tomorrow', 'OTP Bank', 'GATE CODE LANE', + // Lists of places, though every word is on the BIP39 list. + 'coffee, bar, hotel, museum, park, beach, hospital, school, market, bridge, tower, airport', + '1. beach 2. park 3. museum 4. zoo 5. bridge 6. tower 7. market 8. castle 9. island 10. lake 11. river 12. canyon', + 'show only bus, train, car, truck, ship, boat traffic over city bridge today', // 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', @@ -642,9 +646,13 @@ test('a line longer than a place name is never sent for suggestions', async () = }); test('a long line is read quickly', () => { - for (const unit of ['a-', 'a.', '1-', 'a ', '//[a:']) { + for (const line of [ + ...['a-', 'a.', '1-', 'a ', '//[a:'].map((unit) => unit.repeat(10000)), + `otp a${'-'.repeat(20000)}!x`, + `gate code a${'-'.repeat(20000)}!x`, + ]) { const started = performance.now(); - mayBePrivate(unit.repeat(10000)); - assert.ok(performance.now() - started < 1000, unit); + mayBePrivate(line); + assert.ok(performance.now() - started < 1000, line.slice(0, 12)); } }); From 94dcadf54f84b871a1b81f60a060b9852210d74f Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 19:34:48 -0800 Subject: [PATCH 09/14] Tell lists of places from recovery phrases by four map words in any twelve, keep " - thanks" codes private, and trim long tails at once The map words cover 108 BIP39 words for places, buildings, vehicles and the land; twelve list words in a row with four of them are a list of places, which a random phrase is about once in three hundred. A code followed by " - thanks" is private again, and the IPv6 and bearer trims no longer slow on long runs of commas or brackets. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 2 +- src/search/placeSuggestions.js | 48 +++++++++++++++------------- src/search/placeSuggestions.test.mjs | 5 +++ 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 573cb130ff..230c8a88ef 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8117,7 +8117,7 @@ still gets the row: only picking it sends anything. One-time and verification co OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, recovery or seed phrases (twelve words in a row on the BIP39 English list in `src/search/bip39Words.js`, also with commas, numbered or after "my seed -is", so a long question or request still goes to Ask GEV; twelve with three +is", so a long question or request still goes to Ask GEV; twelve with four words for places or things on a map, such as "park", "beach" or "airport", are a list of places), "my secret is …", an email spelled out ("john at example dot com", "punto com", or letter by letter), a door, diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index e3f3e1c938..dbea0c7dec 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -21,14 +21,16 @@ export const minPlaceChars = (text) => (isCjk(text) ? 2 : 3); */ const MAP_WORDS = new Set( ( - 'airport bar beach bike boat bridge bus cafe car castle city coast coffee ' + - 'country desert east elevator ferry fire flight forest garden harbor ' + - 'hospital hotel house island lake market moon mountain museum north ' + - 'ocean office park planet pizza rain river road rocket satellite school ' + - 'sea ship shop snow south space station storm street sun ' + - 'swim taxi tower town traffic train truck tunnel valley village ' + - 'weather west wind world zoo canyon church stadium bank restaurant ' + - 'map area today tomorrow near' + 'airport alley arena bar beach bike boat border bridge bus cabin camp ' + + 'canal canyon capital car castle cave city cliff clinic coast coffee ' + + 'country cruise dentist desert dune east elevator farm field fire ' + + 'flight forest gallery garage garden gym harbor hill hospital hotel ' + + 'island jungle kitchen lake library market meadow moon mountain museum ' + + 'nation north ocean office opera palace park pizza planet police pond ' + + 'pool rail rain ranch region ridge river road rocket route school sea ' + + 'ship shop ski snow soccer south space square stadium street subway sun ' + + 'swamp taxi tennis tornado tower town traffic train truck tunnel valley ' + + 'van vessel village volcano wagon weather west wine zoo' ).split(' '), ); @@ -194,7 +196,9 @@ function privacyReason(text) { // groups with "::", or five colons or more (a time has two). if ( line.split(' ').some((token) => { - const bare = token.replace(/^[[(]+|[\]),.;]+$/g, '').replace(/%\w+$/, ''); + const bare = token + .replace(/^[[(]+|(?<=[^\]),.;])[\]),.;]+$/g, '') + .replace(/%\w+$/, ''); const colons = (bare.match(/:/g) || []).length; return ( /^[0-9a-f:.]+$/i.test(bare) && @@ -211,23 +215,23 @@ function privacyReason(text) { // Written with commas, numbered ("1. abandon 2. ability") or after a few // words ("my seed is …"): twelve of the list's words in a row. The list // has many words for places and things on a map, and a phrase is drawn at - // random from all of it: twelve with three of those ("coffee, bar, - // hotel, museum, park …") is a list of places. - let run = 0; - let mapWords = 0; + // random from all of it: twelve with four of those ("coffee, bar, hotel, + // museum, park …") are a list of places, which a phrase is about once in + // three hundred. + const recent = []; for (const token of line.toLowerCase().split(/[\s,;]+/)) { const word = token .replace(/^\d+[.)]?/, '') .replace(/(?<=[a-z])[^a-z]+$/, ''); if (!word && token) continue; if (!isBip39Word(word)) { - run = 0; - mapWords = 0; + recent.length = 0; continue; } - run += 1; - if (MAP_WORDS.has(word)) mapWords += 1; - if (run >= 12 && mapWords < 3) return 'other'; + recent.push(MAP_WORDS.has(word)); + if (recent.length > 12) recent.shift(); + if (recent.length === 12 && recent.filter(Boolean).length < 4) + return 'other'; } // Coordinates and grid references are a spot, not a number to keep: only // text the place search itself reads as coordinates, as typed ("١٢٣٤, @@ -385,7 +389,7 @@ function privacyReason(text) { function bearerToken(line) { if (/\bauthori[sz]ation\s*:\s*bearer\b\s*\S/i.test(line)) return true; for (const match of line.matchAll(/\bbearer\b(\s*[:=#]?\s*)(\S+)/gi)) { - const value = match[2].replace(/[,.;:!?)]+$/, ''); + const value = match[2].replace(/(?<=[^,.;:!?)])[,.;:!?)]+$/, ''); // Only a word after a space may be a name: "Bearer: island" is a token. if (/^\s+$/.test(match[1]) && PLACE_WORDS.test(value)) continue; return true; @@ -410,7 +414,7 @@ function codeAfterLabel(line) { // After a label in lower case, any value is a code ("verification code // Abc"); after one written as a name, only a value that is not one. const coded = - /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,63})(?:(?:\s*[,;]\s*|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,63})(?:(?:\s*[,;]\s*|\s+-+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if (coded) { @@ -437,7 +441,7 @@ function codeAfterLabel(line) { } // A value in mixed case that is no name ("PIN aBcD", "gate code aBcD"). const mixed = - /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,64})(?:(?:\s*[,;]\s*|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,64})(?:(?:\s*[,;]\s*|\s+-+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if ( @@ -448,7 +452,7 @@ function codeAfterLabel(line) { ) return true; const match = - /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,63})(?:(?:\s*[,;]\s*|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,63})(?:(?:\s*[,;]\s*|\s+-+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if (!match) return false; diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index b6f17b0bd6..e05b6fa3e6 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -470,6 +470,8 @@ test('spelled-out emails, addresses, phrases, codes and short phone numbers stay 'otp ABCDEF thanks!!', 'verification code ABCDEF thanks a lot', 'otp ABCDEF cheers', + 'otp ab12cd - thanks', + 'gate code aBcD - thanks', 'abandon ability able about above absent absorb abstract absurd abuse access accident.', 'abandon, ability, able, about, above, absent, absorb, abstract, absurd, abuse, access, accident', '1. abandon 2. ability 3. able 4. about 5. above 6. absent 7. absorb 8. abstract 9. absurd 10. abuse 11. access 12. accident', @@ -543,6 +545,7 @@ test('places that only looked private are looked up', () => { 'coffee, bar, hotel, museum, park, beach, hospital, school, market, bridge, tower, airport', '1. beach 2. park 3. museum 4. zoo 5. bridge 6. tower 7. market 8. castle 9. island 10. lake 11. river 12. canyon', 'show only bus, train, car, truck, ship, boat traffic over city bridge today', + 'museum, gallery, library, palace, square, alley, canal, garden, hill, cave, farm, field', // 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', @@ -650,6 +653,8 @@ test('a long line is read quickly', () => { ...['a-', 'a.', '1-', 'a ', '//[a:'].map((unit) => unit.repeat(10000)), `otp a${'-'.repeat(20000)}!x`, `gate code a${'-'.repeat(20000)}!x`, + `${','.repeat(20000)}!x`, + `bearer x${','.repeat(20000)}z`, ]) { const started = performance.now(); mayBePrivate(line); From 49ad1b7b7354fcc2e196678b0d9f1c1739cf45c5 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 19:45:38 -0800 Subject: [PATCH 10/14] =?UTF-8?q?Catch=20a=20recovery=20phrase=20numbered?= =?UTF-8?q?=20"(1)=20=E2=80=A6=20(2)=20=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Manjunath Paparaju --- src/search/placeSuggestions.js | 2 +- src/search/placeSuggestions.test.mjs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index dbea0c7dec..c252d2d2a3 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -221,7 +221,7 @@ function privacyReason(text) { const recent = []; for (const token of line.toLowerCase().split(/[\s,;]+/)) { const word = token - .replace(/^\d+[.)]?/, '') + .replace(/^\(?\d+[.)]?/, '') .replace(/(?<=[a-z])[^a-z]+$/, ''); if (!word && token) continue; if (!isBip39Word(word)) { diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index e05b6fa3e6..65a120336c 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -471,6 +471,7 @@ test('spelled-out emails, addresses, phrases, codes and short phone numbers stay 'verification code ABCDEF thanks a lot', 'otp ABCDEF cheers', 'otp ab12cd - thanks', + '(1) abandon (2) ability (3) able (4) about (5) above (6) absent (7) absorb (8) abstract (9) absurd (10) abuse (11) access (12) accident', 'gate code aBcD - thanks', 'abandon ability able about above absent absorb abstract absurd abuse access accident.', 'abandon, ability, able, about, above, absent, absorb, abstract, absurd, abuse, access, accident', From 9b6683a9cdc7afbf80587f65fc7da1d09f2e9e34 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:06:35 -0800 Subject: [PATCH 11/14] Read requests about a map as requests, catch quoted or dash-joined phrases, and an en dash before "thanks" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Words a request about a map is made of (near, today, open, find …) count with the map words, so "find good food open now near this area today" is a request; a phrase is let through about once in a hundred. Phrases quoted, numbered "1:", "#1" or "[1]", or joined by dashes, pipes, slashes or dots are caught, and a code before " – thanks" is private. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 9 ++++--- src/search/placeSuggestions.js | 39 +++++++++++++++++----------- src/search/placeSuggestions.test.mjs | 5 ++++ 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 230c8a88ef..0d7d14fd66 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8116,10 +8116,11 @@ A nine-digit number or a short phone number written with no such word still gets the row: only picking it sends anything. One-time and verification codes, OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, recovery or seed phrases (twelve words in a row on the BIP39 English list -in `src/search/bip39Words.js`, also with commas, numbered or after "my seed -is", so a long question or request still goes to Ask GEV; twelve with four -words for places or things on a map, such as "park", "beach" or "airport", -are a list of places), "my secret is …", an email spelled +in `src/search/bip39Words.js`, also with commas, numbered, quoted, joined by +dashes or slashes, or after "my seed is", so a long question or request +still goes to Ask GEV; twelve with four words for places or for asking about +them, such as "park", "airport", "near" or "today", are a list or a request, +which lets about one phrase in a hundred through), "my secret is …", an email spelled out ("john at example dot com", "punto com", or letter by letter), a door, alarm or lockbox number ("code 4821"; "zip code 90210" and "area code 415" are places), "Authorization: Bearer …", a code in a link (`?code=…`), a diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index c252d2d2a3..879ae5ce69 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -16,8 +16,9 @@ export const isCjk = (text) => CJK.test(String(text || '')); export const minPlaceChars = (text) => (isCjk(text) ? 2 : 3); /** - * Words on the BIP39 list that name places and things on a map, for telling - * a list of places from a recovery phrase. + * Words on the BIP39 list that name places and things on a map, or that a + * request about one is made of, for telling a list of places or a request + * from a recovery phrase. */ const MAP_WORDS = new Set( ( @@ -30,7 +31,12 @@ const MAP_WORDS = new Set( 'pool rail rain ranch region ridge river road rocket route school sea ' + 'ship shop ski snow soccer south space square stadium street subway sun ' + 'swamp taxi tennis tornado tower town traffic train truck tunnel valley ' + - 'van vessel village volcano wagon weather west wine zoo' + 'van vessel village volcano wagon weather west wine zoo ' + + // Words a request about a map is made of. + 'any area around best cheap city close day dinner early find food ' + + 'fresh good hour live local lunch main minute morning near night now ' + + 'old open spot that there this time today tomorrow travel trip view ' + + 'visit walk weekend what when where world' ).split(' '), ); @@ -212,18 +218,21 @@ function privacyReason(text) { // a row on the BIP39 list ("can you tell where the most …" is a // question). Too long to be sent for suggestions anyway, it is kept from // the assistant too. - // Written with commas, numbered ("1. abandon 2. ability") or after a few - // words ("my seed is …"): twelve of the list's words in a row. The list - // has many words for places and things on a map, and a phrase is drawn at - // random from all of it: twelve with four of those ("coffee, bar, hotel, - // museum, park …") are a list of places, which a phrase is about once in - // three hundred. + // Written with commas, numbered ("1. abandon 2. ability"), joined by + // dashes or slashes, or after a few words ("my seed is …"): twelve of + // the list's words in a row. The list has many words for places and for + // asking about them, and a phrase is drawn at random from all of it: + // twelve with four of those ("coffee, bar, hotel, museum, park …", "find + // good food open now near this area") are a list or a request, which a + // phrase is about once in a hundred. const recent = []; - for (const token of line.toLowerCase().split(/[\s,;]+/)) { + for (const token of line.toLowerCase().split(/[\s,;|/.\-\u2013\u2014]+/)) { + // Numbered ("1.", "(1)", "1:", "#1", "[1]") or quoted words; "and" + // before the last word joins it. const word = token - .replace(/^\(?\d+[.)]?/, '') + .replace(/^["'([#]*\d*[)\]:]?["'(]*/, '') .replace(/(?<=[a-z])[^a-z]+$/, ''); - if (!word && token) continue; + if (!word || word === 'and') continue; if (!isBip39Word(word)) { recent.length = 0; continue; @@ -414,7 +423,7 @@ function codeAfterLabel(line) { // After a label in lower case, any value is a code ("verification code // Abc"); after one written as a name, only a value that is not one. const coded = - /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,63})(?:(?:\s*[,;]\s*|\s+-+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,63})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if (coded) { @@ -441,7 +450,7 @@ function codeAfterLabel(line) { } // A value in mixed case that is no name ("PIN aBcD", "gate code aBcD"). const mixed = - /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,64})(?:(?:\s*[,;]\s*|\s+-+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,64})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if ( @@ -452,7 +461,7 @@ function codeAfterLabel(line) { ) return true; const match = - /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,63})(?:(?:\s*[,;]\s*|\s+-+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,63})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( line, ); if (!match) return false; diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index 65a120336c..223a683201 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -471,6 +471,10 @@ test('spelled-out emails, addresses, phrases, codes and short phone numbers stay 'verification code ABCDEF thanks a lot', 'otp ABCDEF cheers', 'otp ab12cd - thanks', + 'gate code aBcD – thanks', + '"abandon ability able about above absent absorb abstract absurd abuse access accident"', + 'abandon-ability-able-about-above-absent-absorb-abstract-absurd-abuse-access-accident', + '#1 abandon #2 ability #3 able #4 about #5 above #6 absent #7 absorb #8 abstract #9 absurd #10 abuse #11 access #12 accident', '(1) abandon (2) ability (3) able (4) about (5) above (6) absent (7) absorb (8) abstract (9) absurd (10) abuse (11) access (12) accident', 'gate code aBcD - thanks', 'abandon ability able about above absent absorb abstract absurd abuse access accident.', @@ -547,6 +551,7 @@ test('places that only looked private are looked up', () => { '1. beach 2. park 3. museum 4. zoo 5. bridge 6. tower 7. market 8. castle 9. island 10. lake 11. river 12. canyon', 'show only bus, train, car, truck, ship, boat traffic over city bridge today', 'museum, gallery, library, palace, square, alley, canal, garden, hill, cave, farm, field', + 'find any good cheap fresh food open now near this area today', // 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', From 406a5003e0f1f7748ceb957da55bfb79e26ff156 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:17:39 -0800 Subject: [PATCH 12/14] Keep a code private before "thanks," with a trailing comma Co-authored-by: Manjunath Paparaju --- src/search/placeSuggestions.js | 6 +++--- src/search/placeSuggestions.test.mjs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index 879ae5ce69..6438b804e5 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -423,7 +423,7 @@ function codeAfterLabel(line) { // After a label in lower case, any value is a code ("verification code // Abc"); after one written as a name, only a value that is not one. const coded = - /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,63})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b((?:otp|2fa|mfa|cvv|cvc|(?:verification|one-time|security|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{2,63})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.,!?]*$/i.exec( line, ); if (coded) { @@ -450,7 +450,7 @@ function codeAfterLabel(line) { } // A value in mixed case that is no name ("PIN aBcD", "gate code aBcD"). const mixed = - /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,64})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b(?:pin|(?:door|access|gate|alarm|entry) code)(?:\s+is)?\s+([a-z0-9-]{4,64})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.,!?]*$/i.exec( line, ); if ( @@ -461,7 +461,7 @@ function codeAfterLabel(line) { ) return true; const match = - /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,63})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.!?]*$/i.exec( + /\b((?:pin|cvv|cvc|otp|2fa|mfa|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)(?:\s+is)?)\s+([a-z0-9][a-z0-9-]{3,63})(?:(?:\s*[,;]\s*|\s+[-–—]+\s+|\s+)(?:thanks|thank you|thx|ty|cheers|please|pls|ok|now)(?:\s+(?:a lot|so much|very much|again))?)?[\s.,!?]*$/i.exec( line, ); if (!match) return false; diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index 223a683201..c310dcfd60 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -471,6 +471,7 @@ test('spelled-out emails, addresses, phrases, codes and short phone numbers stay 'verification code ABCDEF thanks a lot', 'otp ABCDEF cheers', 'otp ab12cd - thanks', + 'gate code aBcD - thanks,', 'gate code aBcD – thanks', '"abandon ability able about above absent absorb abstract absurd abuse access accident"', 'abandon-ability-able-about-above-absent-absorb-abstract-absurd-abuse-access-accident', From bf1e313301bc388902d40a913aec3083019bdaa8 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:39:01 -0800 Subject: [PATCH 13/14] Catch a recovery phrase in curly or angle quotes Co-authored-by: Manjunath Paparaju --- src/search/placeSuggestions.js | 2 +- src/search/placeSuggestions.test.mjs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index 6438b804e5..58d2de1c22 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -230,7 +230,7 @@ function privacyReason(text) { // Numbered ("1.", "(1)", "1:", "#1", "[1]") or quoted words; "and" // before the last word joins it. const word = token - .replace(/^["'([#]*\d*[)\]:]?["'(]*/, '') + .replace(/^["'“”„«‹‘’([{<#]*\d*[)\]:]?["'“”„«‹‘’([{<]*/, '') .replace(/(?<=[a-z])[^a-z]+$/, ''); if (!word || word === 'and') continue; if (!isBip39Word(word)) { diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index c310dcfd60..dbaa7557e2 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -474,6 +474,8 @@ test('spelled-out emails, addresses, phrases, codes and short phone numbers stay 'gate code aBcD - thanks,', 'gate code aBcD – thanks', '"abandon ability able about above absent absorb abstract absurd abuse access accident"', + '“abandon ability able about above absent absorb abstract absurd abuse access accident”', + '«abandon ability able about above absent absorb abstract absurd abuse access accident»', 'abandon-ability-able-about-above-absent-absorb-abstract-absurd-abuse-access-accident', '#1 abandon #2 ability #3 able #4 about #5 above #6 absent #7 absorb #8 abstract #9 absurd #10 abuse #11 access #12 accident', '(1) abandon (2) ability (3) able (4) about (5) above (6) absent (7) absorb (8) abstract (9) absurd (10) abuse (11) access (12) accident', From b363f9b09bf9a71333707f5599b5a080c3aacbb7 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 20:58:22 -0800 Subject: [PATCH 14/14] =?UTF-8?q?Catch=20a=20recovery=20phrase=20quoted=20?= =?UTF-8?q?=C2=BBlike=20this=C2=AB=20or=20=E2=80=9Alike=20this=E2=80=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Manjunath Paparaju --- src/search/placeSuggestions.js | 2 +- src/search/placeSuggestions.test.mjs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index 58d2de1c22..02e37b7bcc 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -230,7 +230,7 @@ function privacyReason(text) { // Numbered ("1.", "(1)", "1:", "#1", "[1]") or quoted words; "and" // before the last word joins it. const word = token - .replace(/^["'“”„«‹‘’([{<#]*\d*[)\]:]?["'“”„«‹‘’([{<]*/, '') + .replace(/^["'“”„‚«»‹›‘’([{<#]*\d*[)\]:]?["'“”„‚«»‹›‘’([{<]*/, '') .replace(/(?<=[a-z])[^a-z]+$/, ''); if (!word || word === 'and') continue; if (!isBip39Word(word)) { diff --git a/src/search/placeSuggestions.test.mjs b/src/search/placeSuggestions.test.mjs index dbaa7557e2..4df112e6ae 100644 --- a/src/search/placeSuggestions.test.mjs +++ b/src/search/placeSuggestions.test.mjs @@ -476,6 +476,7 @@ test('spelled-out emails, addresses, phrases, codes and short phone numbers stay '"abandon ability able about above absent absorb abstract absurd abuse access accident"', '“abandon ability able about above absent absorb abstract absurd abuse access accident”', '«abandon ability able about above absent absorb abstract absurd abuse access accident»', + '»abandon ability able about above absent absorb abstract absurd abuse access accident«', 'abandon-ability-able-about-above-absent-absorb-abstract-absurd-abuse-access-accident', '#1 abandon #2 ability #3 able #4 about #5 above #6 absent #7 absorb #8 abstract #9 absurd #10 abuse #11 access #12 accident', '(1) abandon (2) ability (3) able (4) about (5) above (6) absent (7) absorb (8) abstract (9) absurd (10) abuse (11) access (12) accident',