cvs: pear /Net_SMTP SMTP.php

From: Date: Fri, 04 Apr 2003 07:25:21 +0000
Subject: cvs: pear /Net_SMTP SMTP.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-9737@lists.php.net to get a copy of this message
jon Fri Apr 4 02:25:21 2003 EDT Modified files: /pear/Net_SMTP SMTP.php Log: Perform data quoting in its own routine: quotedata() It is provided as a separate public function to facilitate easier overloading for the cases where it is desirable to customize the quoting behavior. Index: pear/Net_SMTP/SMTP.php diff -u pear/Net_SMTP/SMTP.php:1.33 pear/Net_SMTP/SMTP.php:1.34 --- pear/Net_SMTP/SMTP.php:1.33 Fri Apr 4 02:01:34 2003 +++ pear/Net_SMTP/SMTP.php Fri Apr 4 02:25:21 2003 @@ -640,6 +640,35 @@ } /** + * Quote the data so that it meets SMTP standards. + * + * It is provided as a separate public function to facilitate easier + * overloading for the cases where it is desirable to customize the + * quoting behavior. + * + * @param string The message text to quote. The string must be passed + * by reference, and the text will be modified in place. + * + * @access public + * @since 1.2 + */ + function quotedata(&$data) + { + /* + * Change Unix (\n) and Mac (\r) linefeeds into Internet-standard CRLF + * (\r\n) linefeeds. + */ + $data = preg_replace("/([^\r]{1})\n/", "\\1\r\n", $data); + $data = preg_replace("/\n\n/", "\n\r\n", $data); + + /* + * Because a single leading period (.) signifies an end to the data, + * legitimate leading periods need to be "doubled" (e.g. '..'). + */ + $data = preg_replace("/\n\./", "\n..", $data); + } + + /** * Send the DATA command. * * @param string The message body to send. @@ -664,18 +693,8 @@ } } - /* - * Change Unix (\n) and Mac (\r) linefeeds into Internet-standard CRLF - * (\r\n) linefeeds. - */ - $data = preg_replace("/([^\r]{1})\n/", "\\1\r\n", $data); - $data = preg_replace("/\n\n/", "\n\r\n", $data); - - /* - * Because a single leading period (.) signifies an end to the data, - * legitimate leading periods need to be "doubled" (e.g. '..'). - */ - $data = preg_replace("/\n\./", "\n..", $data); + /* Quote the data based on the SMTP standards. */ + $this->quotedata(&$data); if (PEAR::isError($error = $this->_put('DATA'))) { return $error;

« previous php.pear.cvs (#9737) next »