From 51ad0c2920098beca328d3a033fc7156c3d8bee8 Mon Sep 17 00:00:00 2001 From: Tony Wang Date: Fri, 20 Jan 2023 03:39:05 +0800 Subject: [PATCH] fix #540, duplicate entries in auto fill extension (#593) * fix #540, duplicate entries in auto fill extension `prepareCredentialList` is called twice, once before unlock and once after. If the lists are already prepared, i.e. not empty, skip this step. * fix format and lint --- .../GitRepositorySettingsTableViewController.swift | 1 + pass/Controllers/QRScannerController.swift | 9 +++++---- pass/Services/PasswordDecryptor.swift | 2 +- .../Services/PasswordsTableDataSource.swift | 4 ++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pass/Controllers/GitRepositorySettingsTableViewController.swift b/pass/Controllers/GitRepositorySettingsTableViewController.swift index e37c7c4..2541116 100644 --- a/pass/Controllers/GitRepositorySettingsTableViewController.swift +++ b/pass/Controllers/GitRepositorySettingsTableViewController.swift @@ -172,6 +172,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA // Remember git credential password/passphrase temporarily, ask whether users want this after a successful clone. Defaults.isRememberGitCredentialPassphraseOn = true + // swiftlint:disable:next closure_body_length DispatchQueue.global(qos: .userInitiated).async { do { let transferProgressBlock: (UnsafePointer, UnsafeMutablePointer) -> Void = { git_transfer_progress, _ in diff --git a/pass/Controllers/QRScannerController.swift b/pass/Controllers/QRScannerController.swift index 4693d66..cd9bc1b 100644 --- a/pass/Controllers/QRScannerController.swift +++ b/pass/Controllers/QRScannerController.swift @@ -140,11 +140,12 @@ class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDeleg preferredStyle: .alert ) alertController.addAction(UIAlertAction(title: "Cancel".localize(), style: .default)) - alertController.addAction(UIAlertAction(title: "Settings".localize(), style: .cancel) { _ in - if let url = URL(string: UIApplication.openSettingsURLString) { - UIApplication.shared.open(url) + alertController.addAction( + UIAlertAction(title: "Settings".localize(), style: .cancel) { _ in + if let url = URL(string: UIApplication.openSettingsURLString) { + UIApplication.shared.open(url) + } } - } ) present(alertController, animated: true) } diff --git a/pass/Services/PasswordDecryptor.swift b/pass/Services/PasswordDecryptor.swift index 0e0675a..c97a7c2 100644 --- a/pass/Services/PasswordDecryptor.swift +++ b/pass/Services/PasswordDecryptor.swift @@ -192,7 +192,7 @@ public func yubiKeyDecrypt( extension Data { struct HexEncodingOptions: OptionSet { let rawValue: Int - static let upperCase = HexEncodingOptions(rawValue: 1 << 0) + static let upperCase = Self(rawValue: 1 << 0) } func hexEncodedString(options: HexEncodingOptions = []) -> String { diff --git a/passAutoFillExtension/Services/PasswordsTableDataSource.swift b/passAutoFillExtension/Services/PasswordsTableDataSource.swift index f59bde4..ab4525b 100644 --- a/passAutoFillExtension/Services/PasswordsTableDataSource.swift +++ b/passAutoFillExtension/Services/PasswordsTableDataSource.swift @@ -72,6 +72,10 @@ class PasswordsTableDataSource: NSObject, UITableViewDataSource { return } + guard suggestedPasswordsTableEntries.isEmpty, otherPasswordsTableEntries.isEmpty else { + return + } + for entry in passwordTableEntries { if entry.matches(text) { suggestedPasswordsTableEntries.append(entry)