Skip to content

goodmail 0.4.1: the layout escapes what it writes

Latest

Choose a tag to compare

@rameerez rameerez released this 24 Oct 23:34
· 1 commit to main since this release

A patch release: the default HTML layout now escapes the subject, the preheader and the unsubscribe URL. No migration, no configuration change.

Why

An invoicing app on the fleet puts a merchant's own name into email subjects. A name such as A&B "Shop" <Tienda> broke the <title>, the hidden preheader and the <meta itemprop="name"> attribute, and could add markup to the message. A subject cannot carry HTML entities of its own, so the fix belongs in the layout. The app had stripped <, > and " from subjects as a workaround; it deleted that workaround on upgrading.

What changed

Fixed

  • The layout escapes the subject, the preheader and the unsubscribe URL. The default layout wrote the subject into <title>, the hidden preheader and <meta itemprop="name" content="…">, and the unsubscribe URL into href="…", without HTML escaping. A subject that holds a customer's own words (Invoice from A&B "Shop" <Tienda>) then broke the attribute or added markup, and a subject cannot carry entities of its own. All four values are now escaped with ERB::Util.html_escape. The body stays as the Builder made it. A custom layout (layout_path:) must escape these values itself.

Upgrading

  1. bundle update goodmail.
  2. If you strip characters from subjects to protect the layout, remove that code: the layout escapes.
  3. If you ship a custom layout (layout_path:), escape these four values yourself; the gem cannot reach into your template.

Review

The change was reviewed in an adversarial pass before merge (PR #4), with tests for the four escaped places and for a body that stays as the Builder made it.

Automatically generated notes

What's Changed

  • Escape the subject, the preheader and the unsubscribe URL in the layout by @rameerez in #4

Full Changelog: v0.4.0...v0.4.1