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',