On 2004-11-13 14:09:09 -0500, John Peacock wrote:
> Peter J. Holzer wrote:
> >That was intended. RFC 2821 requires them, and being strict catches
> >quite a bit of spam.
> 
> That's what I figured, but it leads to the question of what the test in 
> question is testing then:

I'll leave that answer to Ask.


>       $as = '[EMAIL PROTECTED]'; # original form
>       ok ($ao = Qpsmtpd::Address->parse($as), "parse $as");
>       is ($ao && $ao->address, $as, "address $as");
> 
> I read the fragment above as testing that the $obj->address method returns 
> just the address (without the delimiters), but since the Q::A->parse() 
> method _requires_ the delimiters, the code should probably be changed to 
> this instead:
> 
>       $as = '[EMAIL PROTECTED]'; # original form
>       ok ($ao = Qpsmtpd::Address->parse("<".$as.">"), "parse $as");
>       is ($ao && $ao->address, $as, "address $as");
> 
> since that will now correctly succeed, and correctly test the 
> $obj->address() method.

Yup.

> I do find it is odd that new() also checks for the delimiters (and strips 
> them if present), but doesn't call canonify() at all.

Yes, you are right, that is odd. I don't quite remember why I did it
that way, but I probably thought that new() would be used for creating
address objects from known addresses, which would not have to checked,
while parse() would be used to parse possibly malformed input. 

This is also similar to Mail::Address, where new() expects its arguments
to be the phrase, the address proper and an optional comment), and parse
tries to figure out what is what from a string.

        hp

-- 
   _  | Peter J. Holzer    | Je h�her der Norden, desto weniger wird
|_|_) | Sysadmin WSR       | �berhaupt gesprochen, also auch kein Dialekt.
| |   | [EMAIL PROTECTED]         | Hallig Gr�de ist fast g�nzlich dialektfrei.
__/   | http://www.hjp.at/ |   -- Hannes Petersen in desd

Attachment: pgpStKqMQZaV3.pgp
Description: PGP signature

Reply via email to