-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix handling external schemes in address bar #493
Conversation
08045d9
to
9c991d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, but one test case fails:
- Enter mailto:[email protected], submit: confirmation popover appears
- Enter define:foo, submit, SERP for "mailto:[email protected]" is opened
This may be a privacy concern sharing some private data to the search
Scenario: 1. Enter `mailto:[email protected]`, submit: confirmation popover appears 2. Without reloading the page, enter a search phrase in the address bar 3. The search is performed for `mailto:[email protected]` This is caused by PermissionAuthorizationQuery deinitializer which calls decisionHandler that ends up requesting a search for the external URL. The query is deinitialized when the new search phrase is submitted and the sequence of events is following: 1. make search URL for the search phrase 2. make search URL for the external URL from a deinitialized PermissionAuthorizationQuery The latter overrides the search phrase and that's how the bug is observed. I updated PermissionModel.queryAuthorization to not call its decision handler at all when decision from query is `.deinitialized`.
Verify that when the query is reset (deinitialized) then decision handler is not called at all.
…ndler:) to make SwiftLint happy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Wonderful! 🏅
May I ask adding the following changes before you merge in order to improve memory usage:
- add (item as? TabBarViewItem)?.clear() to collectionView:didEndDisplayingItem:forRepresentedObjectAtIndexPath: in TabBarViewController.swift
- add usedPermissions = Permissions() to TabBarViewItem.clear() method
- change clearSubscriptions() method to cancellables.removeAll()
This will clear usedPermissions as soon as Tab is closed and so deallocate the Permission Query without delays
@mallexxx is seems that the changes you asked me to make fixed the visual glitch in the address bar 🚀 |
# By Tomas Strba (5) and others # Via GitHub * develop: Refresh the Autofill panel after importing (#496) Require authentication for login export (#494) Observations database clearing improvements (#495) Fix handling external schemes in address bar (#493) New autoconsent rules and move tab cleanup out of onCommitted (#489) Safari CSV Passwords import +LastPass, 1Password (#483) Split preferences into multiple screens and add an option to show full URL (#487) Color of hover label fixed (#497) Add AMP links protection (#488) Enhancements of fire button options (#484) Rename Logins+ to Autofill (#492) new tab page low hanging fruit (#491) Fix threading issues in Autoconsent (#478) Navigation bar improvement: CMD + back or CMD + forward opens a new tab (#486) TextField refactored to TextView in order to make it scrollable (#481) More Xcode cleaning (#485) # Conflicts: # DuckDuckGo.xcodeproj/project.pbxproj # DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Task/Issue URL: https://app.asana.com/0/inbox/1201621708108816/1202055192971137/1202055303685720/f
Tech Design URL:
CC:
Description:
The original issue is about
define:foo
being recognized as an external URL (withdefine:
scheme) and not triggering a search, but instead opening a blank page. I realized that other external URLs don't work either when typed directly into the address bar. I figured out that it's because of a recently modified code in Tab.swift which allows for handling external URLs (optionally converting them to search URLs if they can't be handled byNSWorkspace
) only when the source of a navigation is the main frame. However, when user enters a URL into the address bar, the source of navigation is not main frame either, so I handled it by checking that navigation type is.other
(which covers manually input URLs).Steps to test this PR:
define:foo
triggers a searchsms://+44123123123
tries to open Messages.appmailto:[email protected]
tries to open a system default Mail apptest://hello
triggers a search, because this scheme is not supported by any app in the systemTesting checklist:
Internal references:
Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM