Page MenuHomePhabricator

html entities replaced twice when displaying an e-mail error on userMailer()
Closed, ResolvedPublic

Description

Author: dionyziz

Description:
This bug occurs when the /includes/UserMailer.php::function userMailer() is
called. For instance from /includes/SpecialPreferences.php::class
PreferencesForm::function savePreferences() when changing the user e-mail
address and $wgEmailAuthentication is set to true, function
/includes/User.php::function sendConfirmationMail() calls
/includes/User.php::function sendMail(), which calls the userMailer() function.
If the server hasn't been set up for sending e-mails, an error will occur. The
error message displayed is something similar to the following:

Error sending mail: mail() [<a href='function.mail'>function.mail</a>]: Failed
to connect to mailserver at &quot;localhost&quot; port 25, verify your
&quot;SMTP&quot; and &quot;smtp_port&quot; setting in php.ini or use ini_set()

Notice the &quot; entities, which should instead be displayed as double question
marks ("like this"). This shows that the message is passed to htmlspecialchars()
or htmlentities() twice (first in userMailer() and for a second time when the
page is rendered), causing this confusing output.


Version: 1.5.x
Severity: trivial

Details

Reference
bz2446

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 8:31 PM
bzimport set Reference to bz2446.

dionyziz wrote:

Patch to fix the problem

I added a line on /includes/UserMailer.php, which is the following:

$wgErrorString = html_entity_decode( $wgErrorString );

before passing $wgErrorString to wfDebug(). This should fix the problem.

Attached:

Please submit a patch, that is whole file :/

marco wrote:

Apparently, the offending stuff isn't even present any more, the output when mail() fails is static now (line 216).