Re: Mail/RFC822.php

From: Date: Fri, 26 Sep 2003 08:07:58 +0000
Subject: Re: Mail/RFC822.php
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-22060@lists.php.net to get a copy of this message
# mj@php.net / 2003-09-26 09:50:36 +0200: > On Thu Sep 25, 2003 at 08:2100PM -0600, Richard Bateman wrote: > > I don't know who this needs to go to, so I am sending it here. I have > > recently started using the PEAR Mail classes, including the file RFC822.php > > > > I have had to copy it outside of my PEAR dir structure because as > > packaged I am unable to use it. In the code there is a line that has a > > potential (and frequent) Notice on it that is blocked with an "@" > > symbol. PLEASE PLEASE PLEASE do not do this in your code. We use a > > custom error handler which catches all notices (as potential data > > errors) and kills the script, and if this error is there it will get > > thrown whether or not there is an "@" on the line. Many are not aware > > of this problem (I wasn't until recently) > > > > If someone is in a position to fix the file, I do not know how to create > > a patch, but starting on line 623 (I think), the code needs to be > > changed as follows to make it work: > > It looks like this has already been fixed in the latest CVS version. At > least I couldn't find a place where @ is used to suppres notices in > RFC822.php. great news, that bug has been pissing me off for too long. ;) but there's more: * _validateAddress() contains "weak" code in this regard * _validateLocalPart() contains this bug see attached patch. -- If you cc me or remove the list(s) completely I'll most likely ignore your message. see http://www.eyrie.org./~eagle/faqs/questions.html

Index: Mail/Mail/RFC822.php =================================================================== RCS file: /repository/pear/Mail/Mail/RFC822.php,v retrieving revision 1.10 diff -u -u -r1.10 RFC822.php --- Mail/Mail/RFC822.php 27 Jul 2003 02:02:55 -0000 1.10 +++ Mail/Mail/RFC822.php 26 Sep 2003 07:57:09 -0000 @@ -418,6 +418,7 @@ function _validateAddress($address) { $is_group = false; + $addresses = array(); if ($address['group']) { $is_group = true; @@ -458,7 +459,7 @@ // Check that $addresses is set, if address like this: // Groupname:; // Then errors were appearing. - if (!isset($addresses)){ + if (!count($addresses)){ $this->error = 'Empty group.'; return false; } @@ -847,6 +848,7 @@ function _validateLocalPart($local_part) { $parts = explode('.', $local_part); + $words = array(); // Split the local_part into words. while (count($parts) > 0){
« previous php.pear.dev (#22060) next »