Skip to content

fix(sanitizer): place Vimeo DNT in the URL query - #4724

Merged
fguillot merged 3 commits into
miniflux:mainfrom
Kuriyeatsuchi:fix/vimeo-iframe-dnt-query
Dec 2, 2026
Merged

fguillot merged 3 commits into
miniflux:mainfrom
Kuriyeatsuchi:fix/vimeo-iframe-dnt-query

Conversation

@Kuriyeatsuchi

@Kuriyeatsuchi Kuriyeatsuchi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add dnt=1 to Vimeo player URLs through the URL's query instead of appending it to the raw link. Fragments and existing parameters are kept, and an existing dnt value is replaced instead of duplicated. Other parameters keep their order and encoding.

Motivation

The raw-string append put dnt=1 after any # fragment, so a URL like https://player.vimeo.com/video/123456#chapter became ...#chapter?dnt=1 and Vimeo never received it. A URL that already had dnt=0 or dnt=1 also ended up with two dnt values.

Testing

  • Replaced the two Vimeo tests with one table-driven test covering fragments, queries with and without fragments, replacing dnt=0, keeping dnt=1, duplicate dnt values, no query, semicolons, invalid escapes like %zz, bare flags, and other parameters keeping their encoding.
  • go test ./... passes.

Breaking Changes

None. Only the dnt parameter changes; every other parameter keeps its original order and encoding.

Related Issues

None.

Have you followed these guidelines?

  • I have tested my changes
  • There are no breaking changes
  • I have thoroughly tested my changes and verified there are no regressions
  • My commit messages follow the Conventional Commits specification
  • I have read and understood the contribution guidelines

Append dnt=1 to the raw query instead of returning the link unchanged,
so the iframe still requests Do Not Track.
@fguillot

fguillot commented Dec 1, 2026

Copy link
Copy Markdown
Member

Both of these come from rebuilding the query with url.ParseQuery and Encode():

  1. When parsing fails, the fallback keeps any existing dnt. For example, ?dnt=0&x=%zz becomes ?dnt=0&x=%zz&dnt=1, so the duplicate comes back. It also adds another dnt=1 each time the content is sanitized again, such as after an entry update through the API.
  2. When parsing works, Encode() changes every other parameter. It sorts them, turns bare flags into empty values (?autoplay&muted becomes ?autoplay=&dnt=1&muted=) and escapes characters like , and :. So the embed URL changes beyond dnt.

Editing RawQuery directly fixes both and removes the need for a fallback:

var params []string
for param := range strings.SplitSeq(u.RawQuery, "&") {
	key, _, _ := strings.Cut(param, "=")
	if param != "" && key != "dnt" {
		params = append(params, param)
	}
}
u.RawQuery = strings.Join(append(params, "dnt=1"), "&")
return u.String()

This keeps the other parameters in their original order and encoding. The expected values in the tests would change to match, for example ?title=0&byline=0&dnt=1#chapter. A test case like ?dnt=0&x=%zz would cover the case that used to fall back.

Rebuilding the query with url.ParseQuery and Encode() sorted the
parameters, turned bare flags into empty values and re-escaped other
values. The fallback for unparsable queries also kept an existing dnt
and added another dnt=1 each time the content was sanitized again.

Remove every dnt parameter from the raw query and append dnt=1, so the
other parameters keep their order and encoding.
@Kuriyeatsuchi

Copy link
Copy Markdown
Contributor Author

Good catch, switched to editing RawQuery directly. Other params keep their order and encoding now, and I added tests for ?dnt=0&x=%zz, bare flags and ,/:.

@fguillot
fguillot merged commit c9ba595 into miniflux:main Dec 2, 2026
12 checks passed
@Kuriyeatsuchi
Kuriyeatsuchi deleted the fix/vimeo-iframe-dnt-query branch December 2, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants