Skip to content

Commit

Permalink
Fix brave/brave-ios#7260: Don't auto submit URL from a QR code (brave…
Browse files Browse the repository at this point in the history
  • Loading branch information
stoletheminerals authored Apr 26, 2023
1 parent 366d28a commit 3ed8c44
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1968,11 +1968,11 @@ public class BrowserViewController: UIViewController {
present(settingsNavigationController, animated: true)
}

func popToBVC() {
func popToBVC(completion: (() -> Void)? = nil) {
guard let currentViewController = navigationController?.topViewController else {
return
}
currentViewController.dismiss(animated: true, completion: nil)
currentViewController.dismiss(animated: true, completion: completion)

if currentViewController != self {
_ = self.navigationController?.popViewController(animated: true)
Expand Down Expand Up @@ -2411,8 +2411,11 @@ public class BrowserViewController: UIViewController {

extension BrowserViewController {
func didScanQRCodeWithURL(_ url: URL) {
popToBVC()
finishEditingAndSubmit(url, visitType: .typed)
let overlayText = URLFormatter.formatURL(url.absoluteString, formatTypes: [], unescapeOptions: [])

popToBVC() {
self.topToolbar.enterOverlayMode(overlayText, pasted: false, search: false)
}

if !url.isBookmarklet && !PrivateBrowsingManager.shared.isPrivateBrowsing {
RecentSearch.addItem(type: .qrCode, text: nil, websiteUrl: url.absoluteString)
Expand Down

0 comments on commit 3ed8c44

Please sign in to comment.