NobuNobu
nobun****@users*****
2006年 4月 11日 (火) 22:04:04 JST
Index: xoops2jp/html/class/xoopsmailer.php diff -u xoops2jp/html/class/xoopsmailer.php:1.2 xoops2jp/html/class/xoopsmailer.php:1.2.16.1 --- xoops2jp/html/class/xoopsmailer.php:1.2 Fri Mar 18 21:51:55 2005 +++ xoops2jp/html/class/xoopsmailer.php Tue Apr 11 22:04:04 2006 @@ -1,5 +1,5 @@ <?php -// $Id: xoopsmailer.php,v 1.2 2005/03/18 12:51:55 onokazu Exp $ +// $Id: xoopsmailer.php,v 1.2.16.1 2006/04/11 13:04:04 nobunobu Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -177,14 +177,18 @@ // pupblic function setFromEmail($value) { - $this->fromEmail = trim($value); - } + if ($this->_checkValidEmail($value)) { + $this->fromEmail = trim($value); + } + } // public function setFromName($value) { - $this->fromName = trim($value); - } + if ($this->_checkNoneContorolChar($value)) { + $this->fromName = trim($value); + } + } // RMV-NOTIFY // public @@ -198,15 +202,19 @@ // public function setPriority($value) { - $this->priority = trim($value); - } + if ($this->_checkNoneContorolChar($value)) { + $this->priority = trim($value); + } + } // public function setSubject($value) { - $this->subject = trim($value); - } + if ($this->_checkNoneContorolChar($value)) { + $this->subject = trim($value); + } + } // public function setBody($value) @@ -251,8 +259,10 @@ if (!empty($this->priority)) { $this->headers[] = "X-Priority: " . $this->priority; } - $this->headers[] = "X-Mailer: PHP/".phpversion(); - $this->headers[] = "Return-Path: ".$this->fromEmail; + $this->headers[] = "X-Mailer: XOOPS Cube"; + if (!empty($this->fromEmail)) { + $this->headers[] = "Return-Path: ".$this->fromEmail; + } $headers = join($this->LE, $this->headers); } @@ -448,14 +458,16 @@ // public function addHeaders($value) { - $this->headers[] = trim($value).$this->LE; - } + if ($this->_checkNoneContorolChar($value)) { + $this->headers[] = trim($value).$this->LE; + } + } // public function setToEmails($email) { if ( !is_array($email) ) { - if (preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$email) ) { + if ($this->_checkValidEmail($email)) { array_push($this->toEmails, $email); } } else { @@ -485,7 +497,8 @@ if ( !is_array($group) ) { if ( strtolower(get_class($group)) == "xoopsgroup" ) { $member_handler =& xoops_gethandler('member'); - $this->setToUsers($member_handler->getUsersByGroup($group->getVar('groupid'), true)); + $groups=&$member_handler->getUsersByGroup($group->getVar('groupid'),true); + $this->setToUsers($groups, true); } } else { foreach ($group as $g) { @@ -514,5 +527,20 @@ { } + + function _checkNoneContorolChar($text) { + if (preg_match("/[\\0-\\31]/", $text)) { + $this->errors[] = "Invalid Mail Header String."; //ToDo : Use message catalog + return false; + } + return true; + } + function _checkValidEmail($addr) { + if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i",$addr) ) { + $this->errors[] = "Invalid Mail Address Format."; //ToDo : Use message catalog; + return false; + } + return true; + } } ?> \ No newline at end of file