Home » Mail » Mail » Bug #7616
nestGroups defaults to true, not false
Details
| Submitted | 2006-05-12 18:45 UTC |
|---|---|
| From | truth at proposaltech dot com |
| Assigned | jon |
| Status | Closed |
| Package | |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2006-05-12 18:45 UTC] truth at proposaltech dot com
Description:
------------
Mail/RFC822.php speaks for itself. The member
nestGroups is true by default and is only changed
if a non-null parameter is passed. The code
for the constructor and member variable is the
same. I'll paste a bit of RFC822.php into the
"Test script" section below. Actually, the
behavior seems to be more complicated than
true/false. We've been using the default (true)
for years thinking the default was false because
the results hadn't included nesting. It turns
out that is because we'd never encountered a ":"
in a "From" before. If there's no grouping to
be done, it seems that it doesn't nest even
though nestGroups is true. Tricky! I'm not
sure whether this is a bug in the docs or a bug in
the code.
(BTW, php5 doesn't like the check for "$this" on
line 164 of RFC822.php.)
Test script:
---------------
Here is a bit of the RFC822.php:
var $nestGroups = true;
...
function Mail_RFC822($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
...
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
I'm not sure which part of the code decides not
to test if there were no ":"s even though nestGroups
is true. Maybe that should be a separate bug report.
Here's the problem we hit:
<?php
require_once "Mail/RFC822.php";
$raw = " Melitta One:One<MelittaOneOne80337751@sunildada.com>\n";
class A {
function f($raw) {
$addresses = Mail_RFC822::parseAddressList
($raw, 'proposaltech.com');
var_dump($addresses);
if(is_array($addresses) and count($addresses) != 0){
$adr = $addresses[0];
print "$adr->host\n";
} else {
print "Huh?\n";
}
}
};
$a = new A;
$a->f($raw);
?>
Expected result:
----------------
The docs say nestGroups defaults to false, so
I didn't expect nesting. Now that I know
nestGroups actually defaults to true, I would
expect nesting even if I removed the ":" from
the address.
Actual result:
--------------
I got nesting with the example. If I remove
the ":", the nesting goes away.