Thursday, October 04, 2007

Browser detection using known HTML parser bugs

If you've developed webapps then it is likely you've had to detect what browser is accessing the site and then use javascript or CSS to do something special for that browser. This dude has found a way to use known HTML parser rendering bugs to identify Firefox, IE, Safari, Opera, Lynx and other browsers using just plain HTML. Here is some sample code (I must get round to converting this to Java):

print qq{
<img /src\x00="ie.gif"
/> };

This technique is reported to work with many HTML tags, not just IMG. Clever hack!

No comments: