Say I wanted to credit someone's answer in my own answer. I'd normally write something like this:
Using what [Dlamblin] [said], I think the code would look like this: : https://meta.stackoverflow.com/users/459/dlamblin : #1129732
Notice that the said is linked, and if you use Control+L and paste in "#1129732" the 2 will be generated with
http://#1129732. I use a relative link because there's no need to reload the same exact page, so it's nicer for people.
So WMD is throwing in an extra http:// in front of these kinds of relative links. Normally this is helpful for say "google.com/bookmarks" but not in this case;
Shouldn't a leading "#" stop that behavior?
My answer shows that despite the code in the WMD not supporting relative links, there remains a mildly inconvenient route to producing the links. Therefore they probably aren't an XSS threat. This explains why I feel WMD's behavior is imperfect.
Because I do understand that questions are sometimes on another page, Kyle's suggestion of having some kind of link that is either relative if the question is currently on the page, or fully qualified if it is not, would be wonderful. Understandably it'd be some extra work. It's possibly best done as front end JS code which scans for
a tags in the form of
href="#XYZ" and fixes them to
href=document.domain+"/XYZ#XYZ if the corresponding
a tag with
name="XYZ" isn't found on this page.