SymfonyMailerAdjuster::prependBody can generate broken html

Created on 30 November 2023, 7 months ago

If WrapAndConvertEmailAdjuster is enabled for the policy, we have HTML value with html/body tags as the email body.
In this case, we should prepend the text as valid HTML (after body tag, with
tags).

πŸ› Bug report
Status

Fixed

Version

2.3

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine bohart Lutsk, Ukraine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @bohart
  • First commit to issue fork.
  • Status changed to Needs review 7 months ago
  • πŸ‡ΊπŸ‡¦Ukraine Abyss

    @bohart I added checking whether the html_body is already in html format and, in this case, adding the reroute text after the body tag.

  • Status changed to Needs work 7 months ago
  • πŸ‡ΊπŸ‡¦Ukraine bohart Lutsk, Ukraine

    Hi @Abyss,

    1) <body> can have classes, styles, or some additional attributes.
    In this case, the code will not work correctly.
    Let's use preg_match / preg_replace for the proper check and insertion.

    2) If we insert the text inside <body> tag, we should wrap our plain text with <br/> tags to have the correct displaying in the email.
    Once we do this, let's update RerouteEmailHandlerPluginInterface::prependBody method description by adding the proper @params for consistency (it should say that the prepend text value should be a plain text).

    3) Please rename the input argument for the method prependBody from string $body to string $prepend. Because it's a bit confusing now (as it is not actually an email body value).
    Also, let's update the method description in the interface (it says "Set email body." right now, and this is not correct; it should be something like this "Prepends the specified text to the email body.").

      /**
       * Prepends the specified text to the email body.
       *
       * @param string $prepend
       *   A plain text to be prepended to the email body. Line break tags will be added automatically in the case of HTML emails.
       */
      public function prependBody(string $prepend): void;
  • Assigned to Abyss
  • Status changed to Active 7 months ago
  • πŸ‡ΊπŸ‡¦Ukraine Abyss
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • πŸ‡ΊπŸ‡¦Ukraine Abyss

    @bohart I updated to add a replay message to the existing html body and updated the description for the prependBody method.

  • Status changed to Fixed 7 months ago
  • πŸ‡ΊπŸ‡¦Ukraine bohart Lutsk, Ukraine

    Committed to 2.3.x dev branch. It will be a part of the next 2.3 series releases.
    Thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024