Don’t look to IE anymore..

I've been looking at a bug reported for the Chinese site (what's up with China and all those numerical domain names – lucky numbers :)?) 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..

7 thoughts on “Don’t look to IE anymore..

  1. 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.

  2. 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.

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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s