diff --git a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift index bb35d8f52..67e311816 100644 --- a/SignalServiceKit/src/Storage/FullTextSearchFinder.swift +++ b/SignalServiceKit/src/Storage/FullTextSearchFinder.swift @@ -52,7 +52,9 @@ public class FullTextSearchFinder: NSObject { $0.count > 0 }.map { // Allow partial match of each term. - $0 + "*" + // + // Note that we use double-quotes to enclose each search term. + "\"\($0)\"*" } // 6. Join terms into query string. @@ -92,8 +94,17 @@ public class FullTextSearchFinder: NSObject { var charactersToFilter = CharacterSet.punctuationCharacters charactersToFilter.formUnion(CharacterSet.illegalCharacters) charactersToFilter.formUnion(CharacterSet.controlCharacters) - // Note that we strip the Unicode "subtitute" character (26). - charactersToFilter.formUnion(CharacterSet(charactersIn: "+~$^=|<>`_\u{26}")) + + // We want to strip all ASCII characters except: + // * Letters a-z, A-Z + // * Numerals 0-9 + // * Whitespace + var asciiToFilter = CharacterSet(charactersIn: UnicodeScalar(0x0)!.. YapDatabaseFullTextSearchTransaction? { return transaction.ext(FullTextSearchFinder.dbExtensionName) as? YapDatabaseFullTextSearchTransaction