12

Hyperlinks which contain any of the dollar symbol $, the asterisk symbol * or the apostrophe/single-quote symbol ' cause various things to break:

The [qux](http://...) and [qux][reference] syntaxes do produce valid URLs but unnecessarily percent-escape such characters (whereas they do not percent-escape some invalid characters, such as the double-quote symbol ").

In STD 66, the above characters are defined amongst the sub-delims grammar production:

sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
              / "*" / "+" / "," / ";" / "="

And the pchar production makes clear that such characters are valid in path segments unencoded:

pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"

1. The post preview does not render any hyperlink at all for this case.

6
  • 1
    I can understand why this may be a problem in some very small edge cases - but how often does this really happen? Commented Mar 16, 2013 at 21:05
  • @RichardJ.RossIII: I only noticed it because it came up here.
    – eggyal
    Commented Mar 16, 2013 at 21:06
  • http://foo.com/~bar works! :D I use that one a lot...
    – animuson StaffMod
    Commented Mar 16, 2013 at 21:08
  • * is going to break stuffs (note that it is used for italic, bold, italic bold, bullet point also) so I think it is reasonable not to support it. $ and ' are probably OK.
    – nhahtdh
    Commented Mar 17, 2013 at 23:30
  • @nhahtdh: $ is used for MathJax syntax on sites that have that enabled, like math.stackexchange.com. Commented Mar 18, 2013 at 1:26
  • 1
    @nhahtdh: + is also used for bullet points, but that works okay. Parsers should be able to determine the context and interpret symbols accordingly; I certainly cannot see any reason why the <a href="..">..</a> syntax should not support such symbols, even if there is some reason that other syntaxes cannot. In any event, it should fail more gracefully than it does in some of the above examples.
    – eggyal
    Commented Mar 19, 2013 at 10:47

1 Answer 1

3

This seems to have been at some point, perhaps due to the CommonMark migration that happened in mid-2020.

For context, the first three links in the question rendered like the following at the time the question was posted:

The bug being reported here was that those characters ($, *, and ') were breaking URLs despite those being valid characters in URLs in the specification.

However, I just made a minor edit to the question to see if the problem was gone. This cleared out the cached rendered HTML at the time the question was posted and re-rendered the post again. The problem seems to be fixed: all of those links now render correctly, with those symbols part of the link.

1
  • 1
    Well spotted. It still seems that there’s some overzealous percent-escaping going on, but the outright rejection of valid characters does as you say appear to have been resolved.
    – eggyal
    Commented Mar 7, 2021 at 7:06

You must log in to answer this question.

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