Page MenuHomePhabricator

MediaWiki fails to send email for users with multibyte characters in their name
Closed, ResolvedPublicBUG REPORT

Description

Setup

  • MediaWiki 1.35.11 (a6b4976) 09:18, 14. Aug. 2023
  • PHP 7.4.3-4ubuntu2.19 (apache2handler)
  • MariaDB 10.3.38-MariaDB-0ubuntu0.20.04.1
  • pear/console_getopt 1.4.3
  • pear/mail 1.4.1
  • pear/mail_mime 1.10.11
  • pear/net_smtp 1.9.1
  • pear/net_socket 1.2.2
  • pear/pear-core-minimal 1.10.13
  • pear/pear_exception 1.0.2

Config

$wgSMTP = [
    'host' => 'mail.your-server.de',
    'IDHost' => 'wiki.example.org',
    'port' => 587,
    'username' => 'noreply@example.org',
    'password' => 'K-Ujp2fqzwmdv7m25aANW9xerjbDxp-J',
    'auth' => true
];

Issue
Email confirmation emails are not sent to users if their user name contains a multibyte character.

Reproduce failiure
Create an account called "A.Wöhl" and try to verify the email address. On the first click of the verification button, MediaWiki informs that the verification email was sent. Since you will not receive an email due to the issue, you click the verification button a second time, an error message appears together with details: Validation failed for: =?UTF-8?Q?A.W=C§=B6hl?=<antonwoehl@gmx.de>

Reproduce success
Create an account called "A.Woehl" and try to verify the very same email address. On the first click of the verification button, the email gets sent, and confirmation is possible.

Mowing "A.Wöhl" to "A.Woehl" allows the user to confirm the email address, which failed with the previous user name containing the multibyte character.

Event Timeline

It could be that there is also a misconfiguration or a too-aggressive configuration of the relaying server at play. I cannot tell, though.

The multibyte char is not a problem in isolation as MediaWiki encodes it properly, the issue seems to be with combination of period/dot character (and possibly others) and a multibyte character.

Validation failed for: =?UTF-8?Q?A.W=C§=B6hl?=<antonwoehl@gmx.de>

Here MediaWiki does not quote the dot because it comes within multibyte string which is already Q-encoded. If the string does not contain multibyte char, MediaWiki will quote the entire string, which is what makes "A.Woehl" to work. Multibyte username sans dot ( e.g "A Wöhl") will also work.

Change 952551 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[mediawiki/core@master] mail: Encode period (ascii 46) if it appears in encoded email header.

https://gerrit.wikimedia.org/r/952551

@Ammarpad Thanks for your insight and for providing a patch for the issue. This is much appreciated. I am puzzled that I seem to be the first to experience the issue. I would have thought this is likely to happen more or less frequently. Well, sometimes ... :)

It would be cool if the patch could be back-ported at least to MW 1.39 LTS.

OK, will backport when merged.

@Ammarpad It appears that nobody detected your patch set yet. Do you happen to know how is working on email integrations to MediaWiki? Probably that person will be able to check your patch set.

Well, apparently no one is working on email component, see Developers/Maintainers#Email. The only volunteer listed seems not active. I already added reviewers who have worked to some degree on the file

I am puzzled that I seem to be the first to experience the issue. I would have thought this is likely to happen more or less frequently. Well, sometimes ... :)

I'm slightly surprised we've not apparently seen this in WMF production...

Reedy moved this task from Blocker to Not a blocker on the MW-1.40-release board.
Reedy moved this task from Blocker to Not a blocker on the MW-1.39-release board.

I'm slightly surprised we've not apparently seen this in WMF production...

It only affects wikis with $wgSMTP. WMF production uses mail().

Change 952551 merged by jenkins-bot:

[mediawiki/core@master] mail: Encode period (ascii 46) if it appears in encoded email header.

https://gerrit.wikimedia.org/r/952551

Change 963363 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[mediawiki/core@REL1_39] mail: Encode period (ascii 46) if it appears in encoded email header.

https://gerrit.wikimedia.org/r/963363

Change 963364 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[mediawiki/core@REL1_40] mail: Encode period (ascii 46) if it appears in encoded email header.

https://gerrit.wikimedia.org/r/963364

Change 963806 had a related patch set uploaded (by Reedy; author: Ammarpad):

[mediawiki/core@REL1_35] mail: Encode period (ascii 46) if it appears in encoded email header.

https://gerrit.wikimedia.org/r/963806

Change 963363 merged by jenkins-bot:

[mediawiki/core@REL1_39] mail: Encode period (ascii 46) if it appears in encoded email header.

https://gerrit.wikimedia.org/r/963363

Change 963364 merged by jenkins-bot:

[mediawiki/core@REL1_40] mail: Encode period (ascii 46) if it appears in encoded email header.

https://gerrit.wikimedia.org/r/963364

Change 963806 merged by jenkins-bot:

[mediawiki/core@REL1_35] mail: Encode period (ascii 46) if it appears in encoded email header.

https://gerrit.wikimedia.org/r/963806

Fantaxtic! Thanks for both resolving the issue and making the changes available in the supported branches. I really appreciate your efforts.