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: make navigator.userAgentData non-empty #34481

Merged
merged 4 commits into from Jun 13, 2022
Merged

Conversation

nornagon
Copy link
Member

@nornagon nornagon commented Jun 8, 2022

Description of Change

Fixes #30201.

Previously, Electron was always overriding the user-agent string, but not the
user-agent metadata. This resulted in navigator.userAgentData being empty,
and Sec-CH-UA headers not being sent.

With this change, the user-agent data is set correctly & should be sent with
Sec-CH-UA and should be visible in navigator.userAgentData. One notable
fact is that the brands field does not contain Electron, only Chromium.
I'm not sure if this is something we want to change.

Checklist

Release Notes

Notes: Fixed missing Sec-CH-UA headers and empty navigator.userAgentData.

@nornagon nornagon added the semver/patch backwards-compatible bug fixes label Jun 8, 2022
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jun 8, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jun 9, 2022
@PalmerAL
Copy link
Contributor

One notable fact is that the brands field does not contain Electron, only Chromium. I'm not sure if this is something we want to change.

This is possibly a preemptive comment, but for my use case, I want the UA header to be identical to Chromium's (and therefore not contain Electron). If you do change this, could you add a way to disable it (or more generally, an API like session.setUserAgent to set the userAgentData, which would be even better)?

@nornagon nornagon merged commit 954fd72 into main Jun 13, 2022
@nornagon nornagon deleted the navigator-useragentdata branch June 13, 2022 16:35
@release-clerk
Copy link

release-clerk bot commented Jun 13, 2022

Release Notes Persisted

Fixed missing Sec-CH-UA headers and empty navigator.userAgentData.

@trop
Copy link
Contributor

trop bot commented Jun 13, 2022

I have automatically backported this PR to "20-x-y", please check out #34524

jkleinsc pushed a commit that referenced this pull request Jun 13, 2022
fix: make navigator.userAgentData non-empty (#34481)

Co-authored-by: Jeremy Rose <jeremya@chromium.org>
@yellow1234
Copy link

I did test with new BrowserWindow/loadURL to:
https://www.bing.com/search?q=car

After this merge the low entropy headers
sec-ch-ua
sec-ch-ua-mobile
sec-ch-ua-platform

Are working, but only from the second request to origin (after response with "Accept-CH" header)
if you test in chrome incognito, you will see that its send those headers from the first request

Also, the high entropy headers aren't working at all
sec-ch-ua-arch
sec-ch-ua-full-version
sec-ch-ua-full-version-list
sec-ch-ua-platform-version
sec-ch-ua-bitness
sec-ch-ua-wow64

Electron never sending those, even after response with "Accept-CH" header
like this:
Accept-CH: Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA

@nornagon
Copy link
Member Author

@yellow1234 please file a new bug with a test case, thanks!

@miniak
Copy link
Contributor

miniak commented Jun 27, 2022

/trop run backport-to 19-x-y

@trop
Copy link
Contributor

trop bot commented Jun 27, 2022

The backport process for this PR has been manually initiated - sending your PR to 19-x-y!

@miniak
Copy link
Contributor

miniak commented Jun 27, 2022

/trop run backport-to 18-x-y

@trop
Copy link
Contributor

trop bot commented Jun 27, 2022

The backport process for this PR has been manually initiated - sending your PR to 18-x-y!

@trop
Copy link
Contributor

trop bot commented Jun 27, 2022

I have automatically backported this PR to "19-x-y", please check out #34757

@trop
Copy link
Contributor

trop bot commented Jun 27, 2022

I have automatically backported this PR to "18-x-y", please check out #34758

@miniak
Copy link
Contributor

miniak commented Jun 27, 2022

/trop run backport-to 17-x-y

@trop
Copy link
Contributor

trop bot commented Jun 27, 2022

The backport process for this PR has been manually initiated - sending your PR to 17-x-y!

@trop
Copy link
Contributor

trop bot commented Jun 27, 2022

I have automatically backported this PR to "17-x-y", please check out #34760

codebytere pushed a commit that referenced this pull request Jun 28, 2022
fix: make navigator.userAgentData non-empty (#34481)

Co-authored-by: Jeremy Rose <jeremya@chromium.org>
codebytere pushed a commit that referenced this pull request Jun 28, 2022
fix: make navigator.userAgentData non-empty (#34481)

Co-authored-by: Jeremy Rose <jeremya@chromium.org>
codebytere pushed a commit that referenced this pull request Jun 28, 2022
fix: make navigator.userAgentData non-empty (#34481)

Co-authored-by: Jeremy Rose <jeremya@chromium.org>
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Possibly broken user agent client hint
7 participants