Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent Mojolicious from character-escaping stash data?

I am trying to send HTML to a template in Mojolicious and am finding that the html is getting replaced with safe strings somewhere along the way.

$self->stash(portalHeaderHtml => "<html>");

Becomes

 &lt;html&gt;

In the source

The template:

<%= $portalHeaderHtml %>

How do I tell it to display HTML and not replace tags?

like image 778
shaneburgess Avatar asked Mar 28 '13 12:03

shaneburgess


1 Answers

Mojolicious::Guides::Rendering suggests using == to disable escaping of characters.

An additional equal sign can be used to disable escaping of the characters <, >, &, ' and " in results from Perl expressions, which is the default to prevent XSS attacks against your application.

<%== '<p>test</p>' %>

Proceed with caution.

like image 96
Zaid Avatar answered Nov 18 '22 01:11

Zaid