Firefox w/ MRA in user agent returns MRA as the browser type
danruss opened this issue · comments
Given the following User Agent:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:24.0) Gecko/20130405 MRA 5.5 (build 02842) Firefox/24.0 (.NET CLR 3.5.30729)
The user_agent library returns "MRA" for the browser and an empty browser version.
The expected output is:
Browser: Firefox
Browser Version: 24.0
I took a stab at modifying the logic to address this. I added the following user agent to uastrings in all_test.go:
{"FirefoxMRA", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:24.0) Gecko/20130405 MRA 5.5 (build 02842) Firefox/24.0 (.NET CLR 3.5.30729)"},
and this to expected:
"Mozilla:5.0 Platform:Windows OS:Windows XP Localization:en-US Browser:Firefox-24.0 Engine:Gecko-20130405 Bot:false Mobile:false",
I then modified browser.go as follows starting at line 61:
} else if engine.name == "Gecko" {
if sections[2].version != "" {
p.browser.Name = sections[2].name
} else {
for _, section := range sections {
if strings.Contains("Chrome,Safari,Firefox,Opera", section.name) {
p.browser.Name = section.name
p.browser.Version = section.version
break
}
}
}
}
I'm not sure that the list of Chrome, Safari, Firefox and Opera is extensive enough. Seamonkey, Camino and others may be additions.
Hi @danruss . Thanks for pointing out this issue! I've fixed this with the user agent that you've given me. I'd like to avoid solutions like your proposed one (it's not a realistic plan to make an expensive call "Contains" with a huge string (with just some browsers, not all of them, it's impossible), as the first parameter).
To be honest, I have no clue what this "MRA" stands for, but I have to go now (I promess I'll investigate about it later :P). Please feel free to re-open this issue if my commit doesn't fix the situation. Also, if the problem still persists, could you provide more user agents ? (with different browsers if possible).
Thanks!