refinery / refinerycms

An extendable Ruby on Rails CMS that supports Rails 6.0+
https://www.refinerycms.com/
MIT License
3.9k stars 1.26k forks source link

Malformed DIV TAG using background url property #3233

Closed cristianoveiga closed 7 years ago

cristianoveiga commented 8 years ago

Hello,

I've installed Refinery on my existing Rails 4.2 application.

Everything works well, except for the following situation:

When I add a div and set a background image, for some reason the HTML generated in the final page has a malformed tag (see attached image).

It's weird because it works for some other CSS attributes/properties, for example: CSS class and width/height.

Please, could you help me with this issue ?

Thank you.

Cristiano Veiga

screen shot 07-25-16 at 11 36 am

bricesanchez commented 8 years ago

Hello,

What is your version of refinery?

It could be the HTML sanitizer.

Did you see any warning in your rails server log?

cristianoveiga commented 8 years ago

Hello Brice,

I'm using refinerycms (3.0.4).

You are right, it's the Sanitizer (see attached).

image

Do you have any idea how can I deal with it ?

Thanks,

Cristiano

bricesanchez commented 8 years ago

The best is to not have inline CSS.

I don't know why it does not allow style this attribute is present in Loofah::HTML5::WhiteList : https://github.com/flavorjones/loofah/blob/v2.0.3/lib/loofah/html5/whitelist.rb#L78

bricesanchez commented 8 years ago

What happens if you add a ; at the end of the CSS definition ?

cristianoveiga commented 8 years ago

Well,

I usually try to not to put inline CSSs most of the times, but for this case I don't see any alternative.

The context is: I wanna be able to customize the background image of some divs in my pages.

I tried to put the ; but I got the same behaviour:

image

Any ideas ?

Thanks again !

bricesanchez commented 8 years ago

Did you find the solution?

cristianoveiga commented 8 years ago

Hi Brice,

Not yet.

Do you have any suggestion ?

Thanks.

bricesanchez commented 8 years ago

On a refinerycms (3.0.3) project, i have:

[...]
      .row
        - if post.images.any?
          .img.mobile style="background-image:url(#{post.images.first.thumbnail(geometry: "720x224").url});"
          .img.desktop style="background-image:url(#{post.images.first.thumbnail(geometry: "270x200").url});"
[...]

And inline style works well.

You probably have a problem in your code.

Could you show me your view ?

bricesanchez commented 7 years ago

Is it fixed for you ?

cristianoveiga commented 7 years ago

Hi Brice,

Sorry for not replying before.

Actually I'm no longer working on this project/company.

In the end, we gave up using Refinery for that purpose.

Thank you so much for your time and feel free to close the issue.

Cristiano

bricesanchez commented 7 years ago

@cristianoveiga thanks for your answer, i close this issue because i'm not able to reproduce the error.