Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Ref #2297: Disable JSContext for any type that is privileged. User mu…
Browse files Browse the repository at this point in the history
…st explicitly initiate action. (#2299)
  • Loading branch information
Brandon-T authored and kylehickinson committed Feb 1, 2020
1 parent 96c43da commit 1375ae2
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1113,13 +1113,19 @@ class BrowserViewController: UIViewController {
return
}

if let webView = tab.webView, let code = url.bookmarkletCodeComponent {
resetSpoofedUserAgentIfRequired(webView, newURL: url)
webView.evaluateJavaScript(code, completionHandler: { _, error in
if let error = error {
log.error(error)
}
})
//Another Fix for: https://github.com/brave/brave-ios/pull/2296
//Disable any sort of privileged execution contexts
//IE: The user must explicitly type OR must explicitly tap a bookmark they have saved.
//Block all other contexts such as redirects, downloads, embed, linked, etc..
if visitType == .typed || visitType == .bookmark {
if let webView = tab.webView, let code = url.bookmarkletCodeComponent {
resetSpoofedUserAgentIfRequired(webView, newURL: url)
webView.evaluateJavaScript(code, completionHandler: { _, error in
if let error = error {
log.error(error)
}
})
}
}
} else {
topToolbar.currentURL = url
Expand Down

0 comments on commit 1375ae2

Please sign in to comment.