Invalid Port Number in href Attribute Breaks DOM in IE7

When writing my Local proxies with IE7 – Solved post, Windows Live Writer helpfully turned http://localhost:xyz/ into a link for me. Unfortunately, this resulted in my WordPress page throwing JS errors on every load.

It turns out that the invalid port number breaks the IE7 DOM, and the WordPress devs (who replied within about 4 hours!) haven’t been able to find a way around the condition.

I have posted a test case here:

http://tatham.oddie.com.au/files/InvalidPortNumberInHrefAttributeBreaksDom/

Annoylingly the Microsoft Connect site for IE7 is closed. I’ve emailed a link to the test case to the IE team via their blog, but if anybody knows of a better way I’d be keen to know.

UPDATE 25/4/07: Links like http://anonymous:@svn.fueladvance2.com/ seem to break it as well as demonstrated if you view my next post in IE7.

4 comments

  1. “Breaks DOM” is a bit too much as it only breaks code that tries to read the href attribute of such a link. Other DOM operations are unaffected.

  2. @Björn: I agree with you that it’s not the entire DOM broken, but I still consider it broken when calls to some DOM methods result in a non-descript crash.

  3. Now it is a crash when the browser throws an easily catchable exception? The invalid argument is most likely thrown by the URI parser which does some strict validation of the given URI. The href is not some random string and for now I am not sure if Firefox’ stripping of invalid URI parts is better than throwing an exception.

    As for the user:password@host case: it was broadly announced that user credentials in URLs are disabled by default in Seven, I cannot remember anyone mentioning this script behavior, though 🙂

Comments are closed.