mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-15 01:35:38 +00:00
core: keep whitelisted query parameters when removing link tracking (#6965)
* core: keep whitelisted query parameters when removing link tracking In safe mode, "remove link tracking" stripped any query parameter whose name started with a known tracking prefix in qsSafeBlacklist, ignoring qsWhitelist. So "list" (e.g. YouTube playlist links) was dropped because "li" (LinkedIn) is a prefix of it, and github's "ref" was dropped too. Make the safe-mode filter consult the whitelist, like the other branches. * docs: plan for keeping whitelisted query parameters when removing link tracking Design doc for the safe-mode sanitizeUri change (PR #6965): why "?list=" was stripped from YouTube links, the root cause (safe mode ignoring qsWhitelist), the fix, what it does/doesn't change, and alternatives considered.
This commit is contained in:
@@ -360,7 +360,7 @@ parseUri s = case U.parseURI U.laxURIParserOptions s of
|
||||
sanitizeUri :: Bool -> U.URI -> Maybe U.URI
|
||||
sanitizeUri safe uri@U.URI {uriAuthority, uriPath, uriQuery = U.Query originalQS} =
|
||||
let sanitizedQS
|
||||
| safe = filter (not . isSafeBlacklisted . fst) originalQS
|
||||
| safe = filter (\(n, _) -> isWhitelisted n || not (isSafeBlacklisted n)) originalQS
|
||||
| isNamePath = case originalQS of
|
||||
p@(n, _) : ps -> (if isWhitelisted n || not (isBlacklisted n) then (p :) else id) $ filter (isWhitelisted . fst) ps
|
||||
[] -> []
|
||||
|
||||
Reference in New Issue
Block a user