Gecko User Agent parsing

From MozillaWiki
Jump to: navigation, search

Authors

  • Dan Witte <dwitte@mozilla.com>

Overview

We should have an expansive MDC doc on how to parse the UA string, and when to parse vs. when to feature-sniff. We currently have https://developer.mozilla.org/en/Gecko_user_agent_string_reference, which provides (some!) detail on what the various components of the UA string in Gecko 2 are.

We currently have the following obsolete or inadequate docs sprinkled around:

https://developer.mozilla.org/en/Browser_Detection_and_Cross_Browser_Support https://developer.mozilla.org/en/Gecko_User_Agent_Strings https://developer.mozilla.org/User_Agent_Strings_Reference

These should all be superseded by a single document. It needs:

1) A thorough description of the most recent (Firefox 4) UA string, and all of its fields. This is partially done in https://developer.mozilla.org/en/Gecko_user_agent_string_reference, and changes were explained in http://hacks.mozilla.org/2010/09/final-user-agent-string-for-firefox-4/.

2) A historical document detailing what the UA string looks like for older versions of Gecko, Firefox, Navigator, etc. This is also partially done via the 'ua.txt' file (linked from the above doc) containing examples of old UAs and other Gecko-based product UAs.

3) A set of parsing algorithms (i.e. sample JS) for properly sniffing and extracting various fields.

4) A set of recommendations on when to use those algorithms vs. when to feature-sniff. geckoisgecko.org has a link to a doc on this: http://articles.sitepoint.com/article/dhtml-utopia-modern-web-design/4

We should also update geckoisgecko.org with a link to this new documentation -- the stuff on there is sparse and obsolete.