Repository navigation
fix(sanitizer): place Vimeo DNT in the URL query - #4724
Merged
Merged
Conversation
Append dnt=1 to the raw query instead of returning the link unchanged, so the iframe still requests Do Not Track.
Member
|
Both of these come from rebuilding the query with
Editing 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 |
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.
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 ,/:. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
dnt=1to Vimeo player URLs through the URL's query instead of appending it to the raw link. Fragments and existing parameters are kept, and an existingdntvalue is replaced instead of duplicated. Other parameters keep their order and encoding.Motivation
The raw-string append put
dnt=1after any#fragment, so a URL likehttps://player.vimeo.com/video/123456#chapterbecame...#chapter?dnt=1and Vimeo never received it. A URL that already haddnt=0ordnt=1also ended up with twodntvalues.Testing
dnt=0, keepingdnt=1, duplicatedntvalues, no query, semicolons, invalid escapes like%zz, bare flags, and other parameters keeping their encoding.go test ./...passes.Breaking Changes
None. Only the
dntparameter changes; every other parameter keeps its original order and encoding.Related Issues
None.
Have you followed these guidelines?