otsukare Thoughts after a day of work

2DVN - The Two Digits Version Number Bug

Yesterday, I was writing about collecting the mistakes that create interoperability issues in Web browsers. So let’s start with a first one. You thought the Y2K bug was the biggest nightmare on Earth, that every servers will stop on the planet with buffer overflows. Well… You have not seen anything.

The Bug

Let me introduce you the 2DVN (Two Digits Version Number) bug. Browser identifies themselves on the Web with a User Agent string. For example, the user agent string for the old version of Opera 9.70 on Linux was:

Opera/9.70 (Linux i686 ; U; en-us) Presto/2.2.0

So far so good. Web developers included javascript scripts in their Web sites to match the name, the character “/”, and finally the version number. Because Web developers were not interested by the minor version number (.70 in our example), they made script matching only the major number (9 here in our example). They add things such as

browserName = Opera;
browserVersion = 9;

and with these were applying different rules. Opera browser proudly, before every other browsers, reached the version 10 beta on June 3, 2009 and then sites started to break everywhere. The issue is that they were doing it the wrong way by taking a substring with a length of 1 character. The value for the two variables were becoming

browserName = Opera;
browserVersion = 1;

The Patch

Sites started to block Opera thinking that it was a bad bot spoofing Opera, or applying the bad rules to the browser thinking that this and that is not supported. You can try to contact all the sites on earth to fix it and we try to do that when we detect this kind of mistakes, but the easiest solution was to do something such as:

Opera/9.80 (Macintosh; Intel Mac OS X 10.6.6; U; fr) Presto/2.7.62 Version/11.00

We kept the first number with 1 digit, so javascript will not break with a two digits number and we added a new string called Version/11.0 displaying the real version number of Opera. This creates issues with stats and analytics software which will not detect the new version of Opera for the same reason explained above, but at least most Web sites were not blocking anymore Opera for no reasons.

The Return Of The Vengeance Of Doom

New libraries have been developed for matching the Version/xx.xx number at the end of the User Agent string such as jQuery browser.version. Guess what… some Web developers are doing again the same mistake by using Javascript code such as:

jQuery.browser.version.substr(0, 1)

I see already some people smiling in the room thinking “Who cares? That is only Opera”. We then can wait with a big smile… Chrome has reached version 7 in two years, upgrading its number every 3 months. IE has reached version 9, the next one is 10. Here an example of code which is currently available on the Web on a cool site:

if ($.browser.msie && jQuery.browser.version.substr(0, 1) == "9") {}

Working to open the Web, solving interoperability issues, helps maintaining an open choice for users. So they can use any browsers to interact, communicate and share on the Web.