Skip to content

[BUG]: Rendering rich text fields in plain text email includes HTML comments and tags #5098

@Sukhpreet-s

Description

@Sukhpreet-s

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In emails where rich text content is shown, it also shows the HTML tags and some random HTML comments (screenshot shown below). This behaviour is seen in development and likely is also happening in production. These emails includes:

  • DistributionMailer.partner_mailer - Sent when a new distribution is created or an existing one is updated.
  • ReminderDeadlineMailer.notify_deadline - Sent on set reminder_day for PartnerGroup or for Organization if reminder_day is not set for PartnerGroup. (In production, this email does not include the rich text content as of yet. But this PR will introduce this feature and it adds rich text content.)
Screenshot of the email:

Expected Behavior

The plain text versions of the emails should not show any HTML (comments or tags).

Steps To Reproduce

  1. Sign in as an org/bank admin user -- for example org_admin1@example.com
  2. In "My Organization" page, ensure that the field Default email text: has some text with some formatting applied. If it's empty, add some text with any formattings.
  3. Pick a Partner for which we'll create a Distribution so that the email is sent -- for example, use partnerPawnee Parent Service -- edit the Partner Information by checking the Do you want this partner to receive emails for distributions and reminders from the system? setting.
  4. Create any Distribution for the Partner selected in the last step.
  5. An email should be sent to the Partner. In development environment, the email is saved under tmp/letter_opener -- Voilà, issue found! 🎉 -- the text.erb version will have the HTML comments and tags which shouldn't be there.

Environment

- OS:Ubuntu 24.04.1 (WSL virtualization)
- Node:
- npm:

Criteria for Completion

  • DistributionMailer.partner_mailer -- the text.erb version of email should not show any HTML comments/tags.

Anything else?

Screenshot of the email:

Additional notes:

This bug is found while working on #5093 PR.

This is where the rich text is rendered:

<%= @default_email_text_interpolated %>

Code of Conduct

  • I've read the Code of Conduct and understand my responsibilities as a member of the Ruby for Good community

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions