Skip to content
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

redcarpet performs unnecessary escape for rendered tag #414

Closed
jylitalo opened this issue Aug 30, 2014 · 3 comments
Closed

redcarpet performs unnecessary escape for rendered tag #414

jylitalo opened this issue Aug 30, 2014 · 3 comments

Comments

@jylitalo
Copy link

When I use rdiscount as markdown parser in jekyll, my liquid tag (at https://github.com/jylitalo/ylitalot-net/blob/master/_plugins/colorbox.rb) will properly render:
<script>$(document).ready(function() {$('a[href$="_l.jpg"]').colorbox();});</script>

If I try to use redcarpet for the same task, it will come out as
<script>$(document).ready(function() {$(&#39;a[href$=&quot;_l.jpg"]&#39;).colorbox();});</script>
which on my case doesn't serve its purpose.

So the problem is that redcarpet somehow seems to escape text from my render method (' character into &#39; and " to &quot;), while rdiscount seems to trust that plugin produces proper html.

@robin850
Copy link
Collaborator

Hello @jylitalo,

Actually Redcarpet performs such escaping for legacy security reasons (see #82). If you want quotes inside script tags not to be escaped, you need to make sure that they aren't in a paragraph:

This will be escaped <script>alert("foo");</script> !

This will not:

<script>alert("bar");</script>

I'm giving it a close ; thanks for spotting this ! :-)

@mattberther
Copy link

This markdown

Testing

<script>
    var var1 = 'en';
    var var2 = '{{ site.url }}'
</script>

Testing

ends up producing the following HTML with Redcarpet 3.2.0

<p>Testing</p>

<p><script>
    var var1 = &#39;en&#39;;
    var var2 = &#39;&#39;
</script></p>

<p>Testing</p>

Not sure what Im missing -- how do I prevent Redcarpet from putting the

tags around the script tags?

@robin850
Copy link
Collaborator

@mattberther : Yep, this is a different bug, this has already been fixed with 0f7f500. Normally, this change is included in Redcarpet 3.2.2 (also see #440).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants