/usr/share/horde/ingo/lib/Form/Type/Longemail.php is in php-horde-ingo 3.2.13-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | <?php
/**
* Copyright 2013-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (ASL). If you
* did not receive this file, see http://www.horde.org/licenses/apache.
*
* @category Horde
* @copyright 2013-2016 Horde LLC
* @license http://www.horde.org/licenses/apache ASL
* @package Ingo
*/
/**
* Do address validation on e-mail forms.
*
* @author Michael Slusarz <slusarz@horde.org>
* @author yann@pleiades.fr.eu.org
* @category Horde
* @copyright 2013-2016 Horde LLC
* @license http://www.horde.org/licenses/apache ASL
* @package Ingo
*/
class Ingo_Form_Type_Longemail extends Horde_Form_Type_longtext
{
/**
*/
public function isValid(&$var, &$vars, $value, &$message)
{
$value = trim($value);
if (empty($value)) {
if ($var->isRequired()) {
$message = _("This field is required.");
return false;
}
return true;
}
$invalid = array();
$rfc822 = $GLOBALS['injector']->getInstance('Horde_Mail_Rfc822');
foreach (explode("\n", $value) as $address) {
try {
$rfc822->parseAddressList($address, array(
'validate' => true
));
} catch (Horde_Mail_Exception $e) {
$invalid[] = $address;
}
}
if (count($invalid)) {
$message = sprintf(
ngettext(
_("\"%s\" is not a valid email address."),
_("\"%s\" are not valid email addresses."),
count($invalid)
),
implode(', ', $invalid)
);
return false;
}
return true;
}
}
|