padrino / padrino-framework

Padrino is a full-stack ruby framework built upon Sinatra.

Home Page:http://www.padrinorb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] 0.15.2 upgrade - padrino tags rendering to html entiries in templates

wakatara opened this issue · comments

Do you want to request a feature or report a bug?

A bug! (but so happy we've upgraded padrino to 0.15.2 and upgrade looking good so far. =] ).

What is the current behavior?

In padrino with haml/sass as rendering engine, padrino tags such as = form_tag url and = favicon_tag etc and all nested haml code below render as thei html entiries (eg. lt& rather than <).

What is the expected behavior?

Expected behaviour is to have them render as < or similar.

Example

!!! 5
%html{:lang => 'en'}
  %head
    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    %meta{:content => 'text/html; charset=utf-8', 'http-equiv' => 'Content-Type'}
    %meta{:name => :viewport, :content => 'width=device-width,initial-scale=1'}
    %title= @title.present? ? "#{@title} | AArk Admin" : "#{pat('login.title')} | AArk Admin"
    =favicon_tag "favicon.ico"
    %link{:href => 'http://fonts.googleapis.com/css?family=Varela', :rel => :stylesheet}
    %link{:href => "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css", :rel => :stylesheet}
    %link{:href => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css", :rel => :stylesheet}
    %link{:href => "https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css", :rel => :stylesheet}
    =stylesheet_link_tag 'app'
  %body
    .modal.fade
    = form_tag url(:sessions, :create), :class=>'login form-horizontal' do
      .modal-header

renders as:

<!DOCTYPE html>
<html lang='en'>
<head>
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<meta content='width=device-width,initial-scale=1' name='viewport'>
<title>Login | AArk Admin</title>
&lt;link href=&quot;/admin/images/favicon.ico?1672408286&quot; rel=&quot;icon&quot; type=&quot;image/ico&quot; /&gt;
<link href='[http://fonts.googleapis.com/css?family=Varela](view-source:http://fonts.googleapis.com/css?family=Varela)' rel='stylesheet'>
<link href='[https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css](view-source:https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css)' rel='stylesheet'>
<link href='[https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css](view-source:https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css)' rel='stylesheet'>
<link href='[https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css](view-source:https://cdn.datatables.net/1.10.13/css/dataTables.bootstrap.min.css)' rel='stylesheet'>
&lt;link href=&quot;/admin/stylesheets/app.css?1672408286&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</head>
<body>
<div class='modal fade'></div>
&lt;form action=&quot;/admin/sessions/create&quot; accept-charset=&quot;UTF-8&quot; class=&quot;login form-horizontal&quot; method=&quot;post&quot;&gt;&amp;lt;div class=&amp;#39;modal-header&amp;#39;&amp;gt;
&amp;lt;div class=&amp;#39;login-logo&amp;#39;&amp;gt;&amp;amp;lt;img src=&amp;amp;quot;/admin/images/logo_text.png?1672408286&amp;amp;quot; alt=&amp;amp;quot;Amphibian Ark&amp;amp;quot; height=&amp;amp;quot;118&amp;amp;quot; width=&amp;amp;quot;200&amp;amp;quot; /&amp;amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class=&amp;#39;base-text&amp;#39; id=&amp;#39;login-text&amp;#39;&amp;gt;
&amp;lt;h3&amp;gt;
&amp;lt;em&amp;gt;Ex Situ&amp;lt;/em&amp;gt;
Program progress login
&amp;lt;/h3&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div class=&amp;#39;modal-body&amp;#39;&amp;gt;
&amp;lt;/div&amp;gt;

Which versions of Ruby, Padrino, Sinatra, Rack, OS are you using? Did this work in previous versions?

Ruby 3.1.3
Padrino 0.15.2
Sinatra 3.0.5
Rack 2.2.5
Haml 6.1.1 (in case it's relevant).
(and worked like a charm in previous versions)

y viva padrino!

Thanks for reporting! Unfortunately that seems like a pretty critical bug, unfortunately that was able to sneak past our test coverage.

If @jkowens or any contributor has the time to investigate and submit a patch, I am happy to rush out a fix. Would be great if we could also add a regression test

@wakatara @nesquena this is due Haml 6. It now escapes html by default, similar to Hamlit.

See:

sinatra/sinatra#1820

k0kubun/hamlit#109

@nesquena @jkowens

Apologies gentlemen... you are indeed correct. The issue seems to be haml 6 (though disbaling html safety with a set and trying the != trick did not seem to work to fix the problem in haml code with a do loop at the end - still getting entities).

I've deprecated to 5.2.2 for now and the system seems to be working as expected so, seriously... super impressed that 0.15.2 is rocking things and seems to be working for a pretty complex app. I'll try to update things to haml 6 over the next little while as I upgrade other things in the app from 4 years back. 8-// I'll repoen the ticket if anything in haml 6 is causing issues with tags.

Will kick the tires some more over the next few days... but, really... well done. Padrino does indeed ride again... =]

Excellent news, thanks again for testing, and glad that it was a known issue with HAML 6 with a straightforward workaround

Thanks again to you two for working on and nudging along this latest release

@wakatara thanks for testing all of this out 😄 I don't really have clear in mind what the Haml 6 changes mean for Sinatra/Padrino use. I was hopeful just using != was the answer. I wonder if you possibly found a Haml bug? Might be worth creating an issue over there.