Skip to content
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

Added URL Sanitizer service and Copy Clean URL item for links #14763

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

spylogsster
Copy link
Contributor

@spylogsster spylogsster commented Aug 23, 2022

Resolves brave/brave-browser#23315

MVP implementation for url sanitization, spec https://docs.google.com/document/d/1ea7eF3s0WTsTlmMPr8LYp5KUyNg8eK4omjizo27qvJE/edit#

  • Added a service that removes url parameters from query according to the rules shipped in resources.
  • Added an item to the sharing hub menu to copy clean url

image

- Added an item to the address bar context menu to copy clean url

image

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

  • Go to any url that meet config's rules and copy clean link.
  • Check copied link should have removed parameters accoiring to the rules.

@spylogsster spylogsster self-assigned this Aug 23, 2022
@spylogsster spylogsster force-pushed the brave-23315 branch 4 times, most recently from 2f8e81c to d090f78 Compare August 23, 2022 20:32
Copy link
Member

@fmarier fmarier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which contextual menu is this hooking into? It looks like it might be the one you get when you right-click on a link. If that's the case, then that was the original idea (the screenshot in the issue), but I ended up changing this in the spec because I realized that these URLs are not fully clean already and so they're more complicated to handle.

What I suggest instead in the spec is to hook into the contextual menu you get when you right-click on the address in the URL bar. That URL will have gone through the debouncer and the regular query filter and so all that's left to remove is the contents of the new JSON list. We can leave the link contextual menu for a later phase.

@spylogsster spylogsster force-pushed the brave-23315 branch 2 times, most recently from 8675a64 to 9011d4a Compare August 24, 2022 15:52
@spylogsster
Copy link
Contributor Author

Which contextual menu is this hooking into? It looks like it might be the one you get when you right-click on a link. If that's the case, then that was the original idea (the screenshot in the issue), but I ended up changing this in the spec because I realized that these URLs are not fully clean already and so they're more complicated to handle.

What I suggest instead in the spec is to hook into the contextual menu you get when you right-click on the address in the URL bar. That URL will have gone through the debouncer and the regular query filter and so all that's left to remove is the contents of the new JSON list. We can leave the link contextual menu for a later phase.

done

@spylogsster spylogsster force-pushed the brave-23315 branch 6 times, most recently from f142e6a to 0881cd8 Compare August 24, 2022 17:37
@rmcfadden3
Copy link

I like it!

@spylogsster spylogsster force-pushed the brave-23315 branch 3 times, most recently from c58b834 to 13730f2 Compare August 25, 2022 10:43
@spylogsster spylogsster changed the title wip: Added URL Sanitizer service and Copy Clean URL item for links Added URL Sanitizer service and Copy Clean URL item for links Aug 25, 2022
@spylogsster spylogsster marked this pull request as ready for review August 25, 2022 10:43
@spylogsster spylogsster requested review from a team as code owners August 25, 2022 10:43
@spylogsster spylogsster force-pushed the brave-23315 branch 4 times, most recently from d301412 to 0d2b039 Compare August 25, 2022 18:31
@spylogsster spylogsster force-pushed the brave-23315 branch 6 times, most recently from 378b971 to 93bc811 Compare August 30, 2022 19:34
@spylogsster spylogsster force-pushed the brave-23315 branch 2 times, most recently from 843a85c to 1e96524 Compare August 30, 2022 22:06
@bsclifton
Copy link
Member

bsclifton commented Aug 30, 2022

I have the code checked out locally and built - but it doesn't seem to be working

Here are the steps I tried:

  1. Build code / launch
  2. Visit https://dev-pages.bravesoftware.com/clean-urls/?brave_testing1=foo&brave_testing2=bar&brave_testing3=keep&&;b&d&utm_content=removethis&e=&f=g&=end
  3. Site doesn't resolve, but that's OK
  4. Right click omnibox and pick ``
    image
  5. Paste the clipboard into Notepad or similar
  6. It still has the brave_testing1=foo and brave_testing2=bar (and other params; URL is identical)

I checked and made sure I have latest component:
image

@bsclifton
Copy link
Member

bsclifton commented Aug 30, 2022

OK seems clean-urls.json in package 1.0.188 only has the contents [], which explains why it didn't work

I opened the file manually (%USERPROFILE%\AppData\local\BraveSoftware\Brave-Browser-Development\User Data\afalakplffnnnlkncjhbmahjfjhmlkal\1.0.188\1\clean-urls.json) and paste in the contents from https://github.com/brave/adblock-lists/blob/master/brave-lists/clean-urls.json

This worked great as expected 👍 Sanitized URL looks like this:
https://dev-pages.bravesoftware.com/clean-urls/?brave_testing3=keep&&;b&d&e=&f=g&=end

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left comments - maybe we can use brave/brave-browser#10188 as the follow up issue?

The list (matching the spec) doesn't seem to be live yet. But as shared, I tested by manually pasting the list from https://github.com/brave/adblock-lists/blob/master/brave-lists/clean-urls.json and it works great

@fmarier
Copy link
Member

fmarier commented Aug 30, 2022

Left comments - maybe we can use brave/brave-browser#10188 as the follow up issue?

I think we should file a separate follow-up issue because we could merge the parsing code between these two features without waiting for the lists to get merged, which is going to be trickier.

@spylogsster spylogsster force-pushed the brave-23315 branch 6 times, most recently from 9ddb83e to 3fa0ced Compare August 31, 2022 14:06
@goodov
Copy link
Member

goodov commented Aug 31, 2022

you need to do WIPE_WORKSPACE. just a rebuild won't work, because there're some dirs left that are not removed automatically.

@bsclifton
Copy link
Member

Created brave/brave-browser#25104 as the follow up for the refactoring 😄👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Copy clean URL" feature
6 participants