Add URL tracking parameter stripping for clipboard#1833
Add URL tracking parameter stripping for clipboard#1833ftlframe wants to merge 2 commits intofuto-org:masterfrom
Conversation
Implements GitHub issue futo-org#556 - automatically removes tracking parameters (utm_*, fbclid, si, etc.) from URLs copied to the clipboard using the ClearURLs ruleset. - Add UrlCleaner.kt utility that parses url-rules.json and strips tracking params - Add ClipboardStripUrlTracking setting (disabled by default) - Modify ClipboardHistoryManager to clean URLs when copied - Modify QuickClip to display cleaned URLs in suggestion bar - Add url-rules.json from ClearURLs project to assets
|
Please sign our contributor license agreement at https://cla.futo.org |
1 similar comment
|
Please sign our contributor license agreement at https://cla.futo.org |
abb128
left a comment
There was a problem hiding this comment.
Thanks for the PR. I haven't tested the changes yet but a couple things stood out to me in the code
| // Clean URL tracking params if enabled | ||
| if (text != null && context.getSettingBlocking(ClipboardStripUrlTracking)) { | ||
| val cleanedText = UrlCleaner.cleanUrl(text); | ||
| if(cleanedText != text) { | ||
| // Update system clipboard with clean URL | ||
| val newClip = ClipData.newPlainText( | ||
| clip.description?.label ?: "text", cleanedText | ||
| ); | ||
|
|
||
| clipboardManager.setPrimaryClip(newClip); | ||
| return; // Exit and trigger onPrimaryClipChanged again with clean text | ||
| } | ||
| } |
There was a problem hiding this comment.
It seems this would discard EXTRA_IS_SENSITIVE if it was set. Do you think it would be better to just avoid touching the clip if it's marked sensitive?
There was a problem hiding this comment.
Good catch, went over my head. I'll add a check to skip cleaning if the clip is marked sensitive
| // We just find the URL in text, discarding the https:// part | ||
| val urlRegex = """https?://\S+""".toRegex(); | ||
|
|
||
| return urlRegex.replace(text) { matchResult -> |
There was a problem hiding this comment.
I'm not sure we should be scanning the string for all URLs and changing them individually. If someone is copying a bunch of code, or a long document, etc, it might be unexpected for the keyboard to silently change URLs in the middle and it might break stuff. What do you think?
There was a problem hiding this comment.
Fair point, I'll change this aswell to be used for the more common case of just copying links and just skip longer documents etc..
Closes #556 - automatically removes tracking parameters
(utm_*, fbclid, si, etc.) from URLs copied to the clipboard using the ClearURLs ruleset.
Testing: