I added a comment to jQuery ID selector not working but something strange is happening. The end code reads "); but SO decided to change that to ";);.


I did not add a ; in front of the ).

To further explain what's happening here, the following:

"http://example.com/." http://example.com/.
"http://example.com." http://example.com.
"http://example.com" http://example.com

renders as:

screenshot 2

  • 4
    Always write code between ` ` (backtick)
    – Alpine
    Mar 19, 2011 at 13:18
  • $("img[id=Char_" + Character + "]").attr("src", "image.xboxlive.com/global/t.584108a4/tile/0/2800d"); could not recreate
    – Alpine
    Mar 19, 2011 at 13:21
  • $("img[id=Char_" + Character + "]").attr("src", "image.xboxlive.com/global/t.584108a4/tile/0/2800d"); could not re-create with link
    – Alpine
    Mar 19, 2011 at 13:28
  • @alpine Though I agree with you, some people don't have back tick on their keyboard. Can you reproduce this on the same post jao posted to, to make sure there aren't differences in comment markdown between meta and SO?
    – Pollyanna
    Mar 19, 2011 at 13:39
  • @Adam Davis Yes, could not re-create on the same post
    – Alpine
    Mar 19, 2011 at 14:23
  • @Adam There's a "code sample" button above the editor too Mar 19, 2011 at 15:44
  • What i did was, I copied the string from the original post, then pasted it into the comment box (where it looked okay) $("img[id='Char_" + Character + "']").attr("src", "image.xboxlive.com/global/t.584108a4/tile/0/2800d"); but now it does the same thing here. it probably is some funny character replacing thing
    – jao
    Mar 19, 2011 at 15:49
  • 1
    @Michael We're talking about comments, and as far as I can see there's no buttons above the comment edit box...
    – Pollyanna
    Mar 19, 2011 at 16:38
  • While I can't reproduce the issue with the given example line of code, it's easy to reproduce with balpha's example below: "http://xyz.com/a/b/c" --> "xyz.com/a/b/c" So the bug is valid, although users really should be putting code into backticks, as has been discussed before some users don't have backticks on their keyboard, and thus far Stack Exchange has chosen not to implement another method of adding code blocks into comments. It would seem that either Stack Exchange should fix this bug or add another method to delineate code blocks in comments.
    – Pollyanna
    Mar 19, 2011 at 16:48
  • @adam define "some people don't have backtick on their keyboard". Maybe some people have no letters on their keyboard, either? Jan 15, 2012 at 2:42
  • 1
    @JeffAtwood meta.stackexchange.com/questions/61235/…
    – Pollyanna
    Jan 15, 2012 at 17:51
  • @AdamDavis. Use RFC 2606 domain names as examples.
    – TRiG
    Jan 27, 2015 at 17:05
  • 4
    How on earth is this "by design"???? And it doesn't only affect code, but bog-standard links within English text. (meta.stackexchange.com/questions/252267/… et al) May 2, 2015 at 14:58
  • Similar scenario happened to me, explained here: meta.stackexchange.com/q/300369/231145 Aug 31, 2017 at 5:09

3 Answers 3


To explain what happens here:


is turned into


The auto-linker sees this as a link to http://xyz.com/a/b/c&quot, so the semicolon is left over, and that's where it suddenly appears from.

Granted, this is isn't exactly the expected result.

  • Interesting. "http://xyz.com/a/b/c" does show this issue: "xyz.com/a/b/c" It's odd that we can't reproduce it with his code line though...
    – Pollyanna
    Mar 19, 2011 at 16:46
  • "xyz.com/a/b/c"
    – Alpine
    Mar 19, 2011 at 16:51
  • "xyz.com/a/b/c"
    – Alpine
    Mar 19, 2011 at 16:52
  • Now I can see ;
    – Alpine
    Mar 19, 2011 at 16:53
  • $("img[id=Char_" + Character + "]").attr("src", "image.xboxlive.com/global/t.584108a4/tile/0/2800d");
    – Alpine
    Mar 19, 2011 at 16:55
  • Wouldn't it make sense to have the auto-linker not even try to create clickable links when the http part is not preceded with some whitespace? On the other hand, maybe punctuation such as preceding dots, commas, and... semicolons, still needs to be allowed then, as some don't properly type a space after those, like:example.com And when allowing those, the semi-colon in the preceding " would still trigger the auto-linking.
    – Arjan
    Mar 3, 2012 at 13:45
  • Granted, this is isn't exactly the expected result. -> So maybe we could get rid of the status-bydesign and give it an deferred or planned? Mar 11, 2018 at 18:18

I was able to reproduce it

We were trying

$("img[id=Char_" + Character + "]").attr("src", "image.xboxlive.com/global/t.584108a4/tile/0/2800d");

But as jao said in the comments

What i did was, I copied the string from the original post, then pasted it into the comment box (where it looked okay) $("img[id='Char_" + Character + "']").attr("src", "image.xboxlive.com/global/t.584108a4/tile/0/2800d";); but now it does the same thing here. it probably is some funny character replacing thing – jao

The code that jao is copy / pasting is

$("img[id=Char_" + Character + "]").attr("src", "http://image.xboxlive.com/global/t.584108a4/tile/0/2800d");

As balpha demonstrated in an example


is turned into


The http:// in the link is the key

Try the code with http:// and see


This behavior is fixed, in that it is working better for all use cases but not perfect in your use case.

As balpha mentioned 7 years ago, the problem is that link extraction happens on HTML and the regular expression that handles it matches http://xyz.com/a/b/c&quot as a URL in http://xyz.com/a/b/c". This is because want trailing semicolons to be treated as punctuation.

I've made things a little smarter now in that:

  1. We never break up HTML entities when parsing URLs in rendered HTML.
  2. We unserialize trailing entities from matched strings and try re-evaluating them.
  3. We exclude trailing semicolons both before and after trailing entities.

Only trailing entities are considered because of other hacks that I was asked not to break.

The combination works nicely for URLs in quotes in lists. In your case, things are better in that the there's not a syntax error in your code, but not perfect because the ) prevents your " from being considered a trailing entity and puts it in the URL.

For code, it's still a best practice to wrap the whole thing in backticks, `, especially since the URL matcher strips off the protocol breaking the code in another way.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .