mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 23:19:25 +08:00

`Nokogiri::HTML.fragment` is a huge hack (a comment in the source code admits this). The current behavior of `Email::Styles` is to try to emulate `fragment` using nokogumbo, but it misses some edge cases. In particular, meta tags in a email template don't make it through to the final email. Instead of treating the provided HTML as an indeterminate fragment, this commit makes `Email::Styles` treat the HTML as a complete document. This means that the generated HTML for an email will now always contain top level structure (a doctype, html, head and body tags). This new behavior is behind a hidden site setting for now and defaults off.