New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible buffer overflow when :link_attributes is used #176

Closed
rmm5t opened this Issue Nov 29, 2012 · 4 comments

Comments

Projects
None yet
4 participants
@rmm5t
Contributor

rmm5t commented Nov 29, 2012

When trying to add custom attributes to links, I started receiving these failed assertions. I've also experienced buffer overflow symptoms.

Assertion failed: (md->work_bufs[BUFFER_SPAN].size == 0), function sd_markdown_render, file markdown.c, line 2527.
Abort trap: 6

So far, I've only been able to reproduce this problem in combination with my application. I'm able to reproduce the problem with some unit tests within the application, but when I try to reproduce the problem in isolation, I can't get the same buffer issues to bubble up.

Nonetheless, the problem only happens when custom :link_attributes are enabled. Here's an example of the renderer I'm using when I'm experiencing the issue:

renderer = Redcarpet::Render::HTML.new(link_attributes: { rel: "nofollow" })
Redcarpet::Markdown.new(renderer, autolink: true)
@tomhughes

This comment has been minimized.

Show comment
Hide comment
@tomhughes

tomhughes Nov 29, 2012

Contributor

I think I can see the problem, and I opened #177 as a possible fix - please try it and see if it solves your problem.

Contributor

tomhughes commented Nov 29, 2012

I think I can see the problem, and I opened #177 as a possible fix - please try it and see if it solves your problem.

@rmm5t

This comment has been minimized.

Show comment
Hide comment
@rmm5t

rmm5t Nov 30, 2012

Contributor

@tomhughes 👍 Good work. That does solve my problem. Thanks!

Closing this issue out and moving the discussion over to #177

Contributor

rmm5t commented Nov 30, 2012

@tomhughes 👍 Good work. That does solve my problem. Thanks!

Closing this issue out and moving the discussion over to #177

@nedzen

This comment has been minimized.

Show comment
Hide comment
@nedzen

nedzen Aug 19, 2015

@rmm5t is it possible to add link attribute nofollow only to some links ? and have a syntax like [linked text here](http://linkhere.com){:rel="nofollow"} or [linked text here](http://linkhere.com)[nofollow]

nedzen commented Aug 19, 2015

@rmm5t is it possible to add link attribute nofollow only to some links ? and have a syntax like [linked text here](http://linkhere.com){:rel="nofollow"} or [linked text here](http://linkhere.com)[nofollow]

@robin850

This comment has been minimized.

Show comment
Hide comment
@robin850

robin850 Aug 20, 2015

Collaborator

@nedzen : Redcarpet doesn't support this syntax out-of-the-box, you can implement something similar with a custom render object like:

class CustomRender < Redcarpet::Render::HTML
  def link(link, title, content)
    if title
      %(<a href="#{link}" #{title}>#{content}</a>)
    else
      %(<a href="#{link}">#{content}</a>)
    end
  end
end

Then you can do something like:

[a link](https://github.com rel="nofollow")
Collaborator

robin850 commented Aug 20, 2015

@nedzen : Redcarpet doesn't support this syntax out-of-the-box, you can implement something similar with a custom render object like:

class CustomRender < Redcarpet::Render::HTML
  def link(link, title, content)
    if title
      %(<a href="#{link}" #{title}>#{content}</a>)
    else
      %(<a href="#{link}">#{content}</a>)
    end
  end
end

Then you can do something like:

[a link](https://github.com rel="nofollow")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment