miscoded

the web is a hack

Don't look to IE anymore..

, ,

I've been looking at a bug reported for the Chinese site 56.com (what's up with China and all those numerical domain names - lucky numbers smile?) Here's a screenshot from a colleague, Opera on the left and Chrome on the right:


Digging a bit, it boils down to a failure in a piece of JavaScript that reads innerHTML of an element and does a regular expression match() that ends up matching nothing. They use a regular expression created from this string:

var sRepeat="<%begin_"+xLev+"[^>]*%>((.|\\n)+?)<%end_"+xLev+"%>"; 


and it's a problem with how the line endings are encoded. The site's code contains typical Windows line endings (newline + carriage returns) but this regular expression assumes that innerHTML will contain newlines and not carriage returns. (This is the \\n part of the regexp. The fix is simply replacing "\\n" with "\\n|\\r".)

Firefox and Chrome return innerHTML with normalized LF line endings. IE and Opera return CRLF in this case, and comments are broken both in IE (8) and Opera for me.

Wait..did I just say that? We break a shiny, mass-market production site because we follow IE closely on a piece of JavaScript IE invented and defined? And IE is broken too??

Wow! The times they are a-changing..

The new Google Maps patch, dissectedeither too old or too modern (!)

Comments

Daniel HendrycksDanielHendrycks Monday, August 1, 2011 2:20:35 PM

up

Hack My BrainHackMyBrain Monday, August 1, 2011 2:51:46 PM

Perhaps they test this site in IE6.I have no IE6 to verify my guess.IE6 is still the largest browser in China,while most Chinese netizens don't realize that they r using it,due to their shell-browsers with IE core.

David Bloomdbloom Monday, August 1, 2011 3:09:47 PM

The really mind-blowing part is that this happened on a Chinese site...as Hack My Brain pointed out, IE has huge market share in China.

sirnh1 Monday, August 1, 2011 4:45:45 PM

That bug surprised me, especially if you consider how popular IE in china is bigeyes
IE has a total of 86%, (see statcounter) I would expect IE to work the rest to fail.

Michael A. Puls IIburnout426 Monday, August 1, 2011 5:36:02 PM

User just ran into a similar issue with Opera and textareas: http://dev.opera.com/forums/findpost.pl?id=10012132

Hallvord R. M. Steenhallvors Tuesday, August 2, 2011 1:35:30 PM

Opera's new HTML5 parser aligns line endings with WebKit and Gecko. We can sitepatch 56.com while waiting for the new parser smile

Charles SchlossChas4 Wednesday, August 10, 2011 3:23:24 PM

bigeyes IE break a site gasp