tanoku/redcarpet — Issue #72: Renderers should consider relative links safe
Author: codyrobbins
Created: 2011-11-23 22:41:29+00:00
State: open

# Problem

Unless there’s some edge cases I’m not thinking off—which there might be—I think renderers should consider links to relative URLs to be safe.

# Solution

Change [this code](https://github.com/tanoku/redcarpet/blob/master/ext/redcarpet/autolink.c#L29) to include `'/'`.

(And while we’re there, shouldn’t that be `mailto:` and not `mailto://`?)

# Example

Given

```ruby
renderer = Redcarpet::Render::HTML.new(safe_links_only: true)
redcarpet = Redcarpet::Markdown.new(renderer)
````

then

```ruby
redcarpet.render('[Foo](/foo)')
````

won’t render a link, but

```ruby
redcarpet.render('[Foo](http://example.com/foo)')
````

will render one.