Home > General > Safari User Agent Strings Are Dumb

Safari User Agent Strings Are Dumb

October 21st, 2009

Sometimes it’s hard to decide which company is worse: Apple or Microsoft. Apple’s web browser, Safari, has the dumbest User-Agent of any browser out there. Opera, Firefox, and even MSIE figured out how to do it correctly. You’d think Apple would be able to figure it out, too.

Generally, people want to know the major revision of a browser. The minor revision is usually not important since most of the time these are just used for reporting statistics. Well, as I’m here setting up a piece software that does simple string searches in the user-agent to determine browser version, I got hung up on Safari. Here’s a basic mapping of User-Agent search terms to corresponding browser versions:

opera6 opera/6
opera6 opera 6
opera7 opera/7
opera7 opera 7
galeon1 galeon/1
explorer3 msie 3.
explorer4 msie 4.
explorer5 msie 5.
explorer6 msie 6.
explorer7 msie 7.
explorer8 msie 8.
konqueror2 konqueror/2
konqueror3 konqueror/3
netscape6 netscape6
netscape7 netscape/7
netscape4 mozilla/4
netscape3 mozilla/3
firefox1 firefox/1
firefox2 firefox/2
safari1 safari/1
safari1 safari/85
safari1 safari/3
safari2 safari/4
safari4 safari/5
chrome chrome/0

So check out those Safari searches. The reason they look that way is because Safari doesn’t report it’s version number as Safari/X. Where there should be a major version number is a WebKit build number or some other useless value. Safari does put the actual version into the User-Agent string, but does it in such a fashion that you either need multiple string searches or regex to figure it out. Check out some Safari User-Agent strings:

Safari 3.1.2:
Mozilla/5.0 (...) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1

Safari 4:
Mozilla/5.0 (...) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9

So by matching Safari/5, you’re actually going to end up with either Safari 3.x or Safari 4.x. Or you could search for “Safari” and then search for “Version/X.” Or you could regex search for “/Version\/4.*Safari/” Of course, this software I’m configuring doesn’t support either of those methods because only a mind-bogglingly stupid browser maker would use this format in their User-Agent string.

Oh, and if you’re wondering why Safari/85 matches Safari 1.x, here’s some 1.x User-Agents:

Mozilla/5.0 (...) AppleWebKit/85.8.5 (KHTML, like Gecko) Safari/85.8.1
Mozilla/5.0 (...) AppleWebKit/125.5.6 (KHTML, like Gecko) Safari/125.12
Mozilla/5.0 (...) AppleWebKit/312.1 (KHTML, like Gecko) Safari/312

General

  1. October 12th, 2010 at 04:04 | #1

    Big Apple fan most of the time but got to agree with you on this one… safari user agent strings are real annoying

  1. No trackbacks yet.