Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Text-Handlebars CPAN distribution.

Report information
The Basics
Id: 88751
Status: open
Priority: 0/
Queue: Text-Handlebars

People
Owner: Nobody in particular
Requestors: jason [...] ynkr.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Text::Handlebars bug
Date: Tue, 17 Sep 2013 13:30:48 -0700
To: bug-Text-Handlebars [...] rt.cpan.org
From: Jason Younker <jason [...] ynkr.org>
Given the following: Show quoted text
> my $handlebars = Text::Handlebars->new; > my $tmpl = qq` > <script> > {{{json}}}; > </script> > > {{#if json}} > {{{json}}} > > <div> > {{{json}}}; > </div> > > <script> > {{{json}}}; > </script> > > {{/if}}`; > $handlebars->render_string($tmpl, {json => '{"foo":"bar"}'});
The HTML produced is: Show quoted text
> <script> {"foo":"bar"}; </script> > {"foo":"bar"} > <div> {"foo":"bar"}; </div> > <script> {&quot;foo&quot;:&quot;bar&quot;}; </script>
The best I can tell, json inside a script tag inside a conditional will be escaped despite triple braces. Jason
Subject: Re: [rt.cpan.org #88751] Text::Handlebars bug
Date: Tue, 17 Sep 2013 17:24:29 -0400
To: Jason Younker via RT <bug-Text-Handlebars [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
It's actually escaping anything inside a conditional: $ perl -MText::Handlebars -E'my $handlebars = Text::Handlebars->new; my $tmpl = qq[<script>\n {{{json}}};\n</script>\n\n{{#if json}}\n {{{json}}}\n\n <div>\n {{{json}}};\n </div>\n\n <script>\n {{{json}}};\n </script>\n\n{{/if}}]; say $handlebars->render_string($tmpl, {json => q[{"foo":"bar"}]})' produces: <script> {"foo":"bar"}; </script> {&quot;foo&quot;:&quot;bar&quot;} <div> {&quot;foo&quot;:&quot;bar&quot;}; </div> <script> {&quot;foo&quot;:&quot;bar&quot;}; </script> I'm guessing you're looking at this inside a web browser, or something else that's processing the results as HTML, since HTML entities are replaced in actual HTML contents, but not in the contents of <script> tags. There still is a bug here somewhere that I need to look into, just wanted to make sure this was clarified for future reference. -doy