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 wrong UCBrowser version for some android user-agents #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ notwebkit:
// 2nd: look for browser-specific instructions (e.g. chrome/34)
// 3rd: infer from OS (iOS only)
func (u *UserAgent) evalBrowserVersion(ua string) {
// if there is a 'version/#' attribute with numeric version, use it -- except for Chrome since Android vendors sometimes hijack version/#
if u.Browser.Name != BrowserChrome && u.Browser.Version.findVersionNumber(ua, "version/") {
// if there is a 'version/#' attribute with numeric version, use it -- except for Chrome and UCBrowser since Android vendors sometimes hijack version/#
if u.Browser.Name != BrowserChrome && u.Browser.Name != BrowserUCBrowser && u.Browser.Version.findVersionNumber(ua, "version/") {
return
}

Expand Down
3 changes: 3 additions & 0 deletions uasurfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ var testUAVars = []struct {
{"UCWEB/2.0 (Java; U; MIDP-2.0; en-US; MicromaxQ5) U2/1.0.0 UCBrowser/9.4.0.342 U2/1.0.0 Mobile",
UserAgent{
Browser{BrowserUCBrowser, Version{9, 4, 0}}, OS{PlatformUnknown, OSUnknown, Version{0, 0, 0}}, DevicePhone}},
{"Mozilla/5.0 (Linux; U; Android 5.1.1; en-US; LG-D722 Build/LMY48Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/12.13.0.718 U3/0.8.0 Mobile Safari/534.30",
UserAgent{
Browser{BrowserUCBrowser, Version{12, 13, 0}}, OS{PlatformLinux, OSAndroid, Version{5, 1, 1}}, DevicePhone}},

// Nokia Browser
// {"Mozilla/5.0 (Series40; Nokia501/14.0.4/java_runtime_version=Nokia_Asha_1_2; Profile/MIDP-2.1 Configuration/CLDC-1.1) Gecko/20100401 S40OviBrowser/4.0.0.0.45",
Expand Down