garretts Tue, 18 Aug 2009 18:58:33 +
Revision: http://svn.php.net/viewvc?view=revisionrevision=287462
Log:
- Fixed bug #28038 (Sent incorrect RCPT TO commands to SMTP server)
Bug: http://bugs.php.net/28038 (Closed) Sent incorrect RCPT TO commands to SMTP
server
Changed paths:
U php/php-src/branches/PHP_5_2/NEWS
U php/php-src/branches/PHP_5_2/win32/sendmail.c
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/win32/sendmail.c
U php/php-src/trunk/win32/sendmail.c
Modified: php/php-src/branches/PHP_5_2/NEWS
===
--- php/php-src/branches/PHP_5_2/NEWS 2009-08-18 18:28:59 UTC (rev 287461)
+++ php/php-src/branches/PHP_5_2/NEWS 2009-08-18 18:58:33 UTC (rev 287462)
@@ -8,6 +8,7 @@
- Fixed bug #49236 (Missing PHP_SUBST(PDO_MYSQL_SHARED_LIBADD)). (Jani)
- Fixed bug #49144 (Import of schema from different host transmits original
authentication details). (Dmitry)
+- Fixed bug #28038 (Sent incorrect RCPT TO commands to SMTP server) (Garrett)
13 Aug 2009, PHP 5.2.11RC1
Modified: php/php-src/branches/PHP_5_2/win32/sendmail.c
===
--- php/php-src/branches/PHP_5_2/win32/sendmail.c 2009-08-18 18:28:59 UTC (rev 287461)
+++ php/php-src/branches/PHP_5_2/win32/sendmail.c 2009-08-18 18:58:33 UTC (rev 287462)
@@ -421,7 +421,7 @@
}
SMTP_SKIP_SPACE(RPath);
- snprintf(Buffer, MAIL_BUFFER_SIZE, MAIL FROM:%s\r\n, RPath);
+ FormatEmailAddress(Buffer, RPath, MAIL FROM:%s\r\n);
if ((res = Post(Buffer)) != SUCCESS) {
return (res);
}
@@ -436,7 +436,7 @@
while (token != NULL)
{
SMTP_SKIP_SPACE(token);
- snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, token);
+ FormatEmailAddress(Buffer, token, RCPT TO:%s\r\n);
if ((res = Post(Buffer)) != SUCCESS) {
efree(tempMailTo);
return (res);
@@ -457,7 +457,7 @@
while (token != NULL)
{
SMTP_SKIP_SPACE(token);
- snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, token);
+ FormatEmailAddress(Buffer, token, RCPT TO:%s\r\n);
if ((res = Post(Buffer)) != SUCCESS) {
efree(tempMailTo);
return (res);
@@ -487,7 +487,7 @@
while (token != NULL)
{
SMTP_SKIP_SPACE(token);
- snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, token);
+ FormatEmailAddress(Buffer, token, RCPT TO:%s\r\n);
if ((res = Post(Buffer)) != SUCCESS) {
efree(tempMailTo);
return (res);
@@ -512,7 +512,7 @@
while (token != NULL)
{
SMTP_SKIP_SPACE(token);
- snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, token);
+ FormatEmailAddress(Buffer, token, RCPT TO:%s\r\n);
if ((res = Post(Buffer)) != SUCCESS) {
efree(tempMailTo);
return (res);
@@ -545,7 +545,7 @@
while (token != NULL)
{
SMTP_SKIP_SPACE(token);
-snprintf(Buffer, MAIL_BUFFER_SIZE, RCPT TO:%s\r\n, token);
+FormatEmailAddress(Buffer, token, RCPT TO:%s\r\n);
if ((res = Post(Buffer)) != SUCCESS) {
efree(tempMailTo);
return (res);
@@ -922,3 +922,30 @@
}
return (lAddr);
} /* end GetAddr() */
+
+
+/*
+// Name: int FormatEmailAddress
+// Input:
+// Output:
+// Description: Formats the email address to remove any content ouside
+// of the angle brackets as per RFC 2821.
+//
+// Returns the invalidly formatted mail address if the are
+// unbalanced (the SMTP server should reject it if it's out of spec.)
+//
+// Author/Date: garretts 08/18/2009
+// History:
+///
+int FormatEmailAddress(char* Buffer, char* EmailAddress, char* FormatString ) {
+ char *tmpAddress1, *tmpAddress2;
+ int result;
+
+ if( (tmpAddress1 = strchr(EmailAddress, '')) (tmpAddress2 = strchr(tmpAddress1, '')) ) {
+ *tmpAddress2 = 0; // terminate the string temporarily.
+ result = snprintf(Buffer, MAIL_BUFFER_SIZE, FormatString , tmpAddress1+1);
+ *tmpAddress2 = ''; // put it back the way it was.
+ return result;
+ }
+ return snprintf(Buffer, MAIL_BUFFER_SIZE , FormatString , EmailAddress );
+} /* end FormatEmailAddress() */
Modified: php/php-src/branches/PHP_5_3/NEWS
===
--- php/php-src/branches/PHP_5_3/NEWS 2009-08-18 18:28:59 UTC (rev 287461)
+++ php/php-src/branches/PHP_5_3/NEWS 2009-08-18 18:58:33 UTC (rev 287462)
@@ -146,6 +146,7 @@
com, Kalle)
- Fixed bug #38091 (Mail() does not use FQDN when sending SMTP helo).
(Kalle, Rick Yorgason)
+- Fixed bug #28038 (Sent incorrect RCPT TO commands to SMTP server) (Garrett)
30 Jun 2009, PHP 5.3.0
- Upgraded bundled PCRE to version 7.9. (Nuno)
Modified: php/php-src/branches/PHP_5_3/win32/sendmail.c
===
--- php/php-src/branches/PHP_5_3/win32/sendmail.c 2009-08-18 18:28:59 UTC (rev 287461)
+++