PHP Markdown 1.0.1b2

John Gruber gruber at fedora.net
Sat Nov 27 22:23:22 EST 2004


Tim Pritlove <tim at ccc.de> wrote on 11/27/04 at 8:54pm:

> > + Fixed problem for links defined with urls that include parens, e.g.:
> >
> >   [1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky)
> >
> >   "Chomsky" was being erroneously treated as the URL's title.
> 
> erroneously?

First, yes, regardless of the characters allowed within a URL, the
above was indeed a bug. Markdown's syntax for link definitions with
titles requires some sort of space between the URL and the title.

This would be a link def with a URL and title:

    [1]: http://example.com/ (title)

This would be a link def with just a URL, which contains parentheses:

    [2]: http://example.com/(title)

(This bug was fixed in Markdown.pl a few versions ago.)


> As far as I recall, parentheses are not valid characters for URLs.

Have you read [RFC 2396] [1] ("Uniform Resource Identifiers (URI): Generic
Syntax")? Quoting from section 2.3:

* * *

2.3. Unreserved Characters

   Data characters that are allowed in a URI but do not have a reserved
   purpose are called unreserved.  These include upper and lower case
   letters, decimal digits, and a limited set of punctuation marks and
   symbols.

      unreserved  = alphanum | mark

      mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"

   Unreserved characters can be escaped without changing the semantics
   of the URI, but this should not be done unless the URI is being used
   in a context that does not allow the unescaped character to appear.

* * *

It seems pretty clear to me that `(` and `)` are perfectly valid
characters within a URI. And they do not need to be escaped for
transport or within markup.

My reading of the older [RFC 1738] [2] ("Uniform Resource Locators
(URL)") leads me to believe that parens have always been valid
characters within http: URLs, in the same way that characters like
the comma are. See section 5, "BNF for specific URL schemes", for
details.


[1]: http://www.ietf.org/rfc/rfc2396.txt
[2]: http://www.ietf.org/rfc/rfc1738.txt

-- 
John Gruber                  |               Daring Fireball
gruber at daringfireball.net    |    <http://daringfireball.net>


More information about the Markdown-discuss mailing list