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

x/website: download.js incorrectly defines browser OS #41537

Closed
ipriver opened this issue Sep 21, 2020 · 1 comment
Closed

x/website: download.js incorrectly defines browser OS #41537

ipriver opened this issue Sep 21, 2020 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ipriver
Copy link
Contributor

ipriver commented Sep 21, 2020

What did you do?

Opened golang.org/doc/install in different browsers using Linux OS.

What did you expect to see?

Expected to see that "Download" button has a filename for Linux.

What did you see instead?

JS incorrectly defines OS as a "Unix" system and because of that user sees an empty button (there's no filename for unix golang binary to download) that redirects him to https://golang.org/dl/ if user clicks it.

How it happens:

navigator.appVersion = 5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 Chrome 85.0.4183.102
JS correctly defines OS as a Linux, but because there is no return it continues executing and gets overwritten when next if statement indexes "X11".

navigator.appVersion = "5.0 (X11)" Firefox 80.0.1
Doesn't have a word "Linux" in it and defines system as "Unix" as it includes "X11".

@gopherbot
Copy link

Change https://golang.org/cl/256318 mentions this issue: doc/install: fixed how JS defines browser OS

@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 22, 2020
@golang golang locked and limited conversation to collaborators Oct 8, 2021
passionSeven added a commit to passionSeven/website that referenced this issue Oct 18, 2022
Updated "detectOS" function to use "userAgent" instead of "appVersion".
It has more info and using that it can be correctly detected that the
user uses Firefox on Linux. Users who want to be incognito can modify
these values in their browsers, so there is no workaround for such rare
cases. Added "else if" statements to prevent overwriting the variable.
Also, added a check that prevents to use "click" on "null" elements (in
case if OS haven't been detected or an element doesn't exist in DOM).

Fixes golang/go#41537
Fixes golang/go#41528

Change-Id: Iab94801008eddc17c039d49c19c98bef7641afeb
GitHub-Last-Rev: 6b891e9757ec61cd8107f53669f8ed1c0b807294
GitHub-Pull-Request: golang/website#17
Reviewed-on: https://go-review.googlesource.com/c/website/+/256318
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Steve Traut <straut@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants