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

Inlined stylesheet is incorrectly encoded #246

Closed
dlouzan opened this issue Nov 8, 2019 · 2 comments
Closed

Inlined stylesheet is incorrectly encoded #246

dlouzan opened this issue Nov 8, 2019 · 2 comments

Comments

@dlouzan
Copy link

dlouzan commented Nov 8, 2019

Hello, I'm working on an MR in gitlab for migrating some of the mailers to use premailer for html emails but I'm having an issue where premailer is entity encoding some of my stylesheet rules when I inline them.

I've tried this with several premailer-rails versions, including the latest release 1.10.3.

There's some stylesheet rules that I need to inline in the header of the html email (particularly using the @media tag that seems not properly supported by premailer). One of them includes a direct descendant rule, and premailer is entity-encoding it to > in the inlined style, even if I tell premailer to ignore it:

    %style{ type: 'text/css', 'data-premailer': 'ignore' }
      = asset_to_string('mailer_client_specific.css').html_safe
  def asset_to_string(name)
    app = Rails.application
    if Rails.configuration.assets.compile
      app.assets.find_asset(name).to_s
    else
      controller.view_context.render(file: File.join('public/assets', app.assets_manifest.assets[name]))
    end
  end

mailer_client_specific.css has a rule like:

  table.wrapper > tbody > tr > td {
    ...
  }

And this is incorrectly generated by premailer in the final html as:

  table.wrapper > tbody > tr > td {
    ...
  }

As soon as I remove premailer processing this works as intended:

      mail(bcc: recipients,
           subject: pipeline_subject(status),
           skip_premailer: true) do |format|
        ...

You can take a look at our code in https://gitlab.com/gitlab-org/gitlab/merge_requests/17699

Any ideas? is this a bug in premailer or am I doing anything wrong? Thanks!

The inspiration for inlining the stylesheet was taken from:

@dlouzan
Copy link
Author

dlouzan commented Nov 13, 2019

This seems to be the same as premailer/premailer#353, sadly no answer in that ticket since 2017 :-(

@fphilipe
Copy link
Owner

fphilipe commented Dec 2, 2019

Closing this as this is clearly an issue on premailer's side. Thanks for reporting though!

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

2 participants