A comma-separated string of emails longer than 128 characters gets quietly truncated on save because of #1360466: Remove maxlength HTML attribute from form elements where #maxlength is >= 128. I am experimenting with changing emails textfield to textarea and will post a patch here if it turns out to be Ok.

Comments

texas-bronius created an issue. See original summary.

texas-bronius’s picture

Well, making the simple change

    $form['emails'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Adhoc email addresses'),

to

    $form['emails'] = [
      '#type' => 'textarea',
      '#title' => $this->t('Adhoc email addresses'),

seems to work just fine for storage, but it would be remiss of me to provide a patch without also updating the text field for help text and to handle expected combos of command and/or line breaks, and the module's existing Tests of getMail() to run it through the paces, and I won't get to that any time soon.

This handles both combos of commas and newlines (or linebreaks for that matter):

      // Adhoc emails.
      $adhoc_emails = array_map('trim', explode(',', $notification->getEmails()));

becomes

      // Adhoc emails.
      $adhoc_emails = array_map('trim', explode(',', preg_replace("/((\r?\n)|(\r\n?))/", ',', $notification->getEmails())));
texas-bronius’s picture

Status: Active » Needs review
StatusFileSize
new1.43 KB

Ok fine here's a patch as described in #2, sans tests. Would someone like to give this a go and also update the Tests to be account for this change?

jhedstrom’s picture

StatusFileSize
new3.47 KB
new4.9 KB

Thanks for finding this issue and fixing it! This adds tests.

  • jhedstrom committed 3cd9439 on 8.x-3.x
    Issue #3088150 by jhedstrom, texas-bronius: Content Moderation...
jhedstrom’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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