10

Compare and contrast how the site renders the following three links:

  1. http://wiki.teamfortress.com/wiki/Civilian_(Classic)
  2. http://wiki.teamfortress.com/wiki/Civilian_(Classic\)
  3. http://wiki.teamfortress.com/wiki/Civilian_%28Classic%29

Source:

1. http://wiki.teamfortress.com/wiki/Civilian_(Classic)
2. http://wiki.teamfortress.com/wiki/Civilian_(Classic\)
3. http://wiki.teamfortress.com/wiki/Civilian_%28Classic%29

The site behaves correctly. Chat... not quite as much. This is how chat renders each of these links:

  1. http://wiki.teamfortress.com/wiki…)
  2. http://wiki.teamfortress.com/wiki…;
  3. http://wiki.teamfortress.com/wiki…

You can see the Stack Exchange RandomSneaky ComplimentarySemicolon* pop up out of nowhere in line 2. You can see this in action here.

What's up with the Stack Exchange RandomSneaky ComplimentarySemicolon*?

*I'm sorry. So, so sorry.

3
5

The MarkdownMini implementation used in comments and chat uses a quick and simple approach to avoiding escaped characters – it simply converts them to HTML entities, so when you slash escape the parenthesis at the end, you're actually getting

text = text.Replace(@"\)", ")");

The autolinker regex doesn't allow for the trailing character to be a semicolon, so it lops it off when taking your URL and you get a link with a href value of

http://wiki.teamfortress.com/wiki/Civilian_(Classic&#41

where the browser ever so helpfully decides that the malformed entity is the closing parenthesis your heart desired.

Not necessarily the most desired behaviour, but short of making the escape process a bit more complicated for this specific case, I'm not sure there's much to be done about it.

4
  • 2
    You've likely confused me for Tim Post
    – Tim Stone
    Jan 6 '13 at 15:05
  • ahh.. Sorry about that.
    – asheeshr
    Jan 6 '13 at 15:05
  • It happens quite often, don't worry ;)
    – Tim Stone
    Jan 6 '13 at 15:06
  • Hmm.. this whole thing wouldn't be a problem if the autolinker were smart enough to swallow trailing close parentheses when there's a corresponding unclosed open parenthesis in the link. Of course, if it's really implemented as just a single regex, that could get a bit tricky. (Not impossible, at least not with modern PCRE variants, but tricky.) Jan 7 '13 at 2:12

You must log in to answer this question.

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