PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Mail » Mail » Bug #9137

_hasUnclosedQuotes() doesn't properly handle a double slash before an end quote

Details

Submitted2006-10-23 06:19 UTC
Fromme at calebbrown dot id dot au
Assignedchagenbu
StatusClosed
PackageMail
PHP Version4.3.11
OSLinux
Roadmaps(Not assigned)

Comments

[2006-10-23 06:19 UTC] me at calebbrown dot id dot au

Description:
------------
When an email address such as '"John Doe\\"
<text@example.com>' is passed to RFC822 to be validated
_hasUnclosedQuotes() is detecting the '\"' at the end of the
string and presumes that the quote has been escaped.

Because it only finds a single opening quote it presumes that
the string has unclosed quotes and thinks that the email
address is invalid.

Test script:
---------------
<?php

require_once("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')
);

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

$parsedAddresses = Mail_RFC822::parseAddressList($address);

if(PEAR::isError($parsedAddresses)) {
echo $address." :: Failed to validate\n";
}
else {
echo $address." :: Parsed\n";
}
}

?>

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

Actual result:
--------------
"John Doe" <test@example.com> :: Parsed
"John Doe\\" <test@example.com> :: Failed to validate