cvs: pear(MAINT_0_10) /Net_NNTP/NNTP Header.php Message.php

From: Date: Fri, 25 Jun 2004 12:19:01 +0000
Subject: cvs: pear(MAINT_0_10) /Net_NNTP/NNTP Header.php Message.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-21109@lists.php.net to get a copy of this message
heino Fri Jun 25 08:19:01 2004 EDT Modified files: (Branch: MAINT_0_10) /pear/Net_NNTP/NNTP Header.php Message.php Log: Possible fix for bug #825 http://cvs.php.net/diff.php/pear/Net_NNTP/NNTP/Header.php?r1=1.10&r2=1.10.2.1&ty=u Index: pear/Net_NNTP/NNTP/Header.php diff -u pear/Net_NNTP/NNTP/Header.php:1.10 pear/Net_NNTP/NNTP/Header.php:1.10.2.1 --- pear/Net_NNTP/NNTP/Header.php:1.10 Fri Oct 10 11:35:22 2003 +++ pear/Net_NNTP/NNTP/Header.php Fri Jun 25 08:19:01 2004 @@ -57,7 +57,7 @@ // | been changes or removed. | // | | // +-----------------------------------------------------------------------+ -// $Id: Header.php,v 1.10 2003/10/10 15:35:22 heino Exp $ +// $Id: Header.php,v 1.10.2.1 2004/06/25 12:19:01 heino Exp $ require_once 'PEAR.php'; @@ -76,7 +76,7 @@ /** * The Net_NNTP_Header class * - * @version $Revision: 1.10 $ + * @version $Revision: 1.10.2.1 $ * @package Net_NNTP * * @author Heino H. Gehlsen <heino@gehlsen.dk> @@ -148,18 +148,22 @@ return $Object; break; - // Object + // Object case is_object($input); switch (true) { // Header case is_a($input, 'net_nntp_header'): - return $input; + $return = new Net_NNTP_Header(); + $return->setFields($input); + return $return; break; // Message case is_a($input, 'net_nntp_message'): - return $input->getHeader(); + $return = new Net_NNTP_Header(); + $return->setFields($input); + return $return; break; // Unknown object/class @@ -172,7 +176,7 @@ case is_string($input); case is_array($input); $Object = new Net_NNTP_Header(); - $R = $Object->setFields($input); + $R = $Object->setFields($input); if (PEAR::isError($R)) { return $R; } @@ -421,11 +425,13 @@ case is_object($input): switch (true) { case is_a($input, 'net_nntp_header'): - $this =& $input; + $this->reset(); + $this->fields = $input->getFields(); break; case is_a($input, 'net_nntp_message'): - $this =& $input->getHeader(); + $h = $input->getHeader(); + $this->setFields($h); break; // Unknown type @@ -610,7 +616,7 @@ // Decode header value acording to RFC 2047 if (($flags & NET_NNTP_HEADER_SET_DECODE) == NET_NNTP_HEADER_SET_UNFOLD) { - $value = $this->decodeString($value); + $value = $this->decodeString($value); } // Add header to $return array @@ -819,7 +825,7 @@ * @access private * @since 0.1 */ - function _foldExplode($string, $maxlen = 78) + function _foldExplode($string, $maxlen = 78) //TODO: { if ($maxlen < 20) { @@ -865,8 +871,8 @@ // {{{ decodeString() /** - * Given a header/string, this function will decode it according to RFC2047. - * Probably not *exactly* conformant, but it does pass all the given + * Given a header/string, this function will decode it according to RFC2047. + * Probably not *exactly* conformant, but it does pass all the given * examples (in RFC2047). * * @param string $input Input header value to decode @@ -890,7 +896,7 @@ switch (strtolower($encoding)) { - case 'b': // RFC2047 4.1 + case 'b': // RFC2047 4.1 $text = base64_decode($text); break; @@ -956,7 +962,7 @@ // TODO: This should be done better... $string = trim($string, "\r\n"); - return $string; + return $string; } // }}} http://cvs.php.net/diff.php/pear/Net_NNTP/NNTP/Message.php?r1=1.7&r2=1.7.2.1&ty=u Index: pear/Net_NNTP/NNTP/Message.php diff -u pear/Net_NNTP/NNTP/Message.php:1.7 pear/Net_NNTP/NNTP/Message.php:1.7.2.1 --- pear/Net_NNTP/NNTP/Message.php:1.7 Sat Aug 16 15:15:04 2003 +++ pear/Net_NNTP/NNTP/Message.php Fri Jun 25 08:19:01 2004 @@ -57,15 +57,15 @@ // | been changes or removed. | // | | // +-----------------------------------------------------------------------+ -// $Id: Message.php,v 1.7 2003/08/16 19:15:04 heino Exp $ +// $Id: Message.php,v 1.7.2.1 2004/06/25 12:19:01 heino Exp $ require_once 'PEAR.php'; require_once 'Net/NNTP/Header.php'; /** - * The Net_NNTP_Message class + * The Net_NNTP_Message class * - * @version $Revision: 1.7 $ + * @version $Revision: 1.7.2.1 $ * @package Net_NNTP * * @author Heino H. Gehlsen <heino@gehlsen.dk> @@ -146,7 +146,8 @@ return $Object; break; - // Object + + // Object case is_object($input): switch (true) { @@ -173,17 +174,17 @@ // Array & String (only 1st parameter) case ((is_string($input) || is_array($input)) && (is_null($input2))): - $Object->setMessage($input); + $Object->setMessage($input); return $Object; break; // Array & String (also 2nd parameter) case ((is_string($input) || is_array($input)) && (is_string($input2) || is_array($input2))): - $Object->setHeader($input); + $Object->setHeader($input); if (is_array($input2)) { - $Object->body = implode("\r\n", $input2); + $Object->body = implode("\r\n", $input2); } else { $Object->body = $input2; } @@ -220,7 +221,8 @@ // Message case is_a($input, 'net_nntp_message'): - $this =& $message; + $this->setHeader($message->getHeader()); + $this->setBody($message->getBody()); break; // Unknown object/class @@ -310,13 +312,13 @@ } break; - // Array & String + // Array & String case is_array($input): case is_string($input): $this->header->setFields($input); break; - // Unknown type + // Unknown type default: return PEAR::throwError('Unsupported type: '. gettype($input), null); } @@ -342,7 +344,7 @@ /** * Sets the body * - * @param mixed $body Array or string + * @param mixed $body Array or string * * @access public */ @@ -378,7 +380,7 @@ * * @param mixed $input Message in form of eiter string or array * - * @return array Contains separated header and body sections in same type as $input + * @return array Contains separated header and body sections in same type as $input * @access public */ function splitMessage($input) @@ -389,7 +391,7 @@ case is_string($input); if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $input, $matches)) { return array('header' => $matches[1], 'body' => $matches[2]); - } else { + } else { return PEAR::throwError('Could not split header and body'); } break;

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