This is getting into an area where Markdown's ambiguities and lenience aren't fixable, because by removing one edge case, you're creating two others. Since this isn't a particularly exciting issue, I'll leave it be; there are enough ways to accomplish what you're trying (related: What's the recommended syntax for an image with a link?), and the new problems that would be introduced by a fix are probably worse than what you have now.
One thing I'm changing though (next build), is the particular way in which this breaks, so it stops creating broken HTML (which then gets eaten by the sanitizer).
After this change, the created HTML still isn't what you expect, but it's a) valid, and b) it makes clear what happens here:
[![](http://phpcode.eu/images/1316518785.php)][1]
is understood like this:
[ just an open bracket; regular text
![ start of an image
... the image alt text
] the end of the alt text
[1] the reference to the image link
so what you're getting in the generated HTML is this (line breaks inserted for clarification):
[<img
src="http://stackoverflow.com"
alt="](http://phpcode.eu/images/1316518785.php)"
>