-
Notifications
You must be signed in to change notification settings - Fork 916
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
Sanitize URL when it is copied into clipboard by JS. #24207
Conversation
ff393b6
to
116bd7a
Compare
constexpr const char kYoutubeRules[] = R"json( | ||
[{ | ||
"include": [ | ||
"*://youtu.be/*?*", |
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.
This can be just *://youtu.be/*
.
81628fd
to
b0c50f5
Compare
browser/brave_browser_features.cc
Outdated
@@ -24,6 +24,10 @@ BASE_FEATURE(kBraveCopyCleanLinkByDefault, | |||
#endif | |||
); | |||
|
|||
BASE_FEATURE(kBraveCopyCleanLinkFromJs, | |||
"brave-copy-clean-link-from-js", |
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.
can we name it BraveCopyCleanLinkFromJs
for ease of search
test/BUILD.gn
Outdated
@@ -1119,6 +1119,7 @@ test("brave_browser_tests") { | |||
"//brave/browser/brave_resources_browsertest.cc", | |||
"//brave/browser/ssl/certificate_transparency_browsertest.cc", | |||
"//brave/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc", | |||
"//brave/browser/url_sanitizer/url_sanitizer_browsertest.cc", |
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.
put it into a sepratate browser_tests target in b/b/url_sanitizer/BUILD.gn
this old way is kinda deprecated
if (!base::FeatureList::IsEnabled(features::kBraveCopyCleanLinkFromJs)) { | ||
return url; | ||
} | ||
DCHECK(render_frame_host); |
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.
} | ||
DCHECK(render_frame_host); | ||
DCHECK(render_frame_host->GetBrowserContext()); | ||
auto* url_sanitizer_service = |
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.
maybe CHECK it as well? is it always non-null in tor/incognito ?
[puLL-Merge] - brave/brave-core@24207 DescriptionThis PR introduces a new feature for sanitizing URLs when copying them to the clipboard. It adds the ability to clean URLs based on predefined rules, particularly focusing on YouTube URLs. The feature can be enabled or disabled using a feature flag. ChangesChanges
Possible Issues
Security Hotspots
This PR significantly enhances Brave's URL handling capabilities, particularly for cleaning potentially sensitive information from URLs before they are copied to the clipboard. The implementation appears thorough, with appropriate test coverage and integration into existing browser components. |
6b26d6e
to
8e2864e
Compare
Resolves brave/brave-browser#33037
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
See in the issue
Enable feature
--enable-features=BraveCopyCleanLinkFromJs
Test page https://boocmp.github.io/clipboard/