File: 9137.phpt

package info (click to toggle)
php-mail 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 172 kB
  • ctags: 306
  • sloc: php: 1,110; xml: 164; makefile: 58
file content (33 lines) | stat: -rwxr-xr-x 1,001 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--TEST--
Mail: Test for bug #9137
--FILE--
<?php

require_once dirname(__FILE__) . '/../Mail/RFC822.php';
require_once 'PEAR.php';

$addresses = array(
    array('name' => 'John Doe', 'email' => 'test@example.com'),
    array('name' => 'John Doe\\', 'email' => 'test@example.com'),
    array('name' => 'John "Doe', 'email' => 'test@example.com'),
    array('name' => 'John "Doe\\', 'email' => 'test@example.com'),
);

for ($i = 0; $i < count($addresses); $i++) {
    // construct the address
    $address = "\"" . addslashes($addresses[$i]['name']) . "\" ".
        "<".$addresses[$i]['email'].">";

    $parsedAddresses = Mail_RFC822::parseAddressList($address);
    if (is_a($parsedAddresses, 'PEAR_Error')) {
        echo $address." :: Failed to validate\n";
    } else {
        echo $address." :: Parsed\n";
    }
}

--EXPECT--
"John Doe" <test@example.com> :: Parsed
"John Doe\\" <test@example.com> :: Parsed
"John \"Doe" <test@example.com> :: Parsed
"John \"Doe\\" <test@example.com> :: Parsed