Skip to content

Commit

Permalink
mode/reduce-tracking: Fix request corruption.
Browse files Browse the repository at this point in the history
STRIP-TRACKING-PARAMETERS added an extra level of percent encoding to
a request which resulted in broken redirect and inability to open
some pages like Google Mail.

Fixes #3402.
  • Loading branch information
shamazmazum authored and aadcg committed May 31, 2024
1 parent c6babcf commit 545f210
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion _build/quri
15 changes: 11 additions & 4 deletions source/mode/reduce-tracking.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ still being less noticeable in the crowd.")
(defun strip-tracking-parameters (request-data)
(let ((mode (find-submode 'reduce-tracking-mode)))
(when (and mode (not (uiop:emptyp (quri:uri-query (url request-data)))))
(setf (quri:uri-query-params (url request-data))
;; Some symbols like : or / are only percent-encoded when they
;; have a special meaning. It is not uncommon to have a link like
;; https://example.com/foo?query=bar&redirect=https://foobar.com
;; The URL in `redirect` part must not be percent encoded.
;; For this purpose we do not alter percent encoding here.
(setf (quri:uri-query-params (url request-data) :percent-encode nil)
(remove-if (rcurry #'member (query-tracking-parameters mode)
:test #'string-equal)
(quri:url-decode-params (quri:uri-query (url request-data)) :lenient t)
:key #'first)))
request-data))
(quri:url-decode-params (quri:uri-query (url request-data))
:lenient t
:percent-decode nil)
:key #'first))))
request-data)

(defmethod enable ((mode reduce-tracking-mode) &key)
(setf (old-timezone mode) (uiop:getenv "TZ")
Expand Down

0 comments on commit 545f210

Please sign in to comment.