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

Fix inability to open Gmail when using reduce-tracking-mode. #3403

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _build/quri
5 changes: 4 additions & 1 deletion source/changelog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ elements are scaled accordingly.")
(define-version "3.11.7"
(:nsection :title "Bug fixes"
(:ul
(:li "Fix query handling when invoking command" (:nxref :command 'set-url) "."))))
(:li "Fix query handling when invoking command" (:nxref :command 'set-url) ".")
(:li "Fix redirect while "
(:nxref :class-name 'nyxt/mode/reduce-tracking:reduce-tracking-mode)
" is active"))))

(define-version "3.11.6"
(:nsection :title "Bug fixes"
Expand Down
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
9 changes: 8 additions & 1 deletion tests/offline/mode/reduce-tracking.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
(in-package :nyxt/tests)

(define-test toggle-reduce-tracking-mode ()
(let ((buffer (make-instance 'network-and-modable-buffer)))
(let ((buffer (make-instance 'network-and-modable-buffer))
(url-pre (quri:uri "https://example.com/query?foo=bar&twclid=1&redirect=https://example.org/foo&s_cid=123"))
(url-post (quri:uri "https://example.com/query?foo=bar&redirect=https://example.org/foo")))
(with-current-buffer buffer
(assert-true (enable-modes* 'nyxt/mode/reduce-tracking:reduce-tracking-mode
buffer))
(assert-equality
#'quri:uri= url-post
(url (nhooks:run-hook
(request-resource-hook buffer)
(make-instance 'request-data :url url-pre))))
(assert-true (disable-modes* 'nyxt/mode/reduce-tracking:reduce-tracking-mode
buffer)))))