pieroxy / java-user-agent-detection

Some code to deduce an OS/Platform/Browser out of a user-agent string
53 stars 12 forks source link

Problem detect Safari 5.1.7 in Windows 7 #2

Closed JuanMiguelBG closed 9 years ago

JuanMiguelBG commented 9 years ago

I've a problem to detect Safari 5.1.7 in Wndows 7. The user agent is:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2

It was detected with the following information:

Family: WebKit-based Description: Safari-like Version:
Full version:
Rendering Engine: WebKit 534.57.2 Is Gecko: No Is Webkit/Blink: Yes Is Trident: No Is a Robot: No

The problem is on the class UserAgentDetector. In the line 1132:

context.contains("Windows NT", MatchingType.BEGINS, MatchingRegion.PARENTHESIS)

The "Windows NT" token was consumed in the SO detection and it's not available in the parenTokens property (used in getToken() method).

In the previous line, you use context.contains("Mac OS", MatchingType.CONTAINS, MatchingRegion.CONSUMED), that i think it's the correct manner.

I added the next line to your code and it's works sucessfully.

|| context.contains("Windows NT", MatchingType.CONTAINS, MatchingRegion.CONSUMED)

pieroxy commented 9 years ago

Thanks. I'll integrate your code and will try to do a release this weekend.

pieroxy commented 9 years ago

Will e in the next release next weekend.