Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari's user agent: which WebKit version to trust?

I'm trying to extract not just the browser and its version number but also the rendering engine and its version number from common user-agent strings. Most browsers report this just fine, e.g.:

  • "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)"

  • "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.12) Gecko/2009070611 Firefox/3.5.12"

Safari also reports the WebKit version number, but it seems to do so twice. Here's my own UA:

  • "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9.1"

In this case, it seems that one is just more detailed than the other.

But when I look at databases of Safari UA strings, e.g. useragentstring.com, the two versions are often entirely different.

  • "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532+ (KHTML, like Gecko) Version/4.0.2 Safari/530.19.1"

  • "Mozilla/5.0 (Windows; U; Windows NT 5.1; cs-CZ) AppleWebKit/525.28.3 (KHTML, like Gecko) Version/3.2.3 Safari/525.29"

  • "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19.1"

  • "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/528.4+ (KHTML, like Gecko) Version/4.0dp1 Safari/526.11.2"

Etc.

Which one do I use? It's not a major issue, but just wondering. Thanks!

like image 726
Aseem Kishore Avatar asked Sep 03 '09 00:09

Aseem Kishore


1 Answers

The AppleWebKit/xxx section tells you which rendering engine is being used. The Version/xxx Safari/xxx section tells you which version of the "Browser Frontend" is being used.

Webkit nightly builds run the currently installed Safari frontend with the latest nightly rendering engine doing the rendering. This is why you can get different AppleWebKit/xxx numbers with the same Version/xxx Safari/xxx.

like image 118
edds Avatar answered Sep 28 '22 09:09

edds