PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_IMAP » Bug #8715

possibility to set key toupper at getParsedHeaders()

Details

Request #8715possibility to set key toupper at getParsedHeaders()
Submitted2006-09-15 18:22 UTC
Fromsebling at gmx dot net
Assignedamistry
StatusClosed
PackageNet_IMAP
PHP Version5.1.4
OSLinux (Debian Etch)
Roadmaps(Not assigned)

Comments

[2006-09-15 18:22 UTC] sebling at gmx dot net

Description:
------------
It should be possible to set the keys toupper.

Some headers are different depending to the MUA. For example the message-id can be "Message-Id" or "Message-ID".

This makes it hard to get the values of some attriutes.

Test script:
---------------
[...]
$messageList = $mbox->getMessagesList();
foreach($messageList as $message) {
$headers = $mbox->getParsedHeaders($message['msg_id']);
$message_ids[] = $headers['Message-Id'];
}
[...]

with this changes
http://stud.umwelt-campus.de/~ai0321/pear/getParsedHeaders/Net_IMAP.diff
you can do:
[...]
$messageList = $mbox->getMessagesList();
foreach($messageList as $message) {
$headers = $mbox->getParsedHeaders($message['msg_id'], true);
$message_ids[] = $headers['MESSAGE-ID']; // maybe depending on your locale
}
[...]

Expected result:
----------------
Array
(
[0] => <1d41be3c0609140920i3e6ee43aw2f3b274efbed4dcb@mail.gmail.com>
[1] => <200609142018.34318.foobar@foo.bar>
[2] => <200609151001.43897.barfoo@bar.foo>
)

Actual result:
--------------
for the first example you may get someting like this because of message-id like "Message-ID":
Array
(
[0] =>
[1] => <200609142018.34318.foobar@foo.bar>
[2] => <200609151001.43897.barfoo@bar.foo>
)

[2006-09-15 18:29 UTC] sebling at gmx dot net

I know the diff don't show up only my changes. I've edited the tabs to fit the coding rules from pear.

My changes are:
- function getParsedHeaders($msg_id)
+ function getParsedHeaders($msg_id, $keysToUpper = false)
[...]
foreach ($raw_headers as $value) {
$name = substr($value, 0, $pos = strpos($value, ':'));
+ if ($keysToUpper) {
+ $name = strtoupper($name);
+ }
$value = ltrim(substr($value, $pos + 1));

And of course the addition in the comment block

--
Sebastian

[2006-09-15 18:44 UTC] amistry at php dot net

Added to the CVS. Please confirm it works for you. Thanks.

[2006-09-18 13:16 UTC] sebling at gmx dot net

Tested and works for me.

Sebastian

[2006-12-11 16:46 UTC] amistry at php dot net

This bug has been fixed in CVS.

If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.