Re: [Patch] Use str_replace instead of preg_replace inNet_SMTP/SMTP.php
| From: | Jon Parise | Date: | Sun, 19 Sep 2004 17:26:55 +0000 |
| Subject: | Re: [Patch] Use str_replace instead of preg_replace inNet_SMTP/SMTP.php | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33453@lists.php.net to get a copy of this message | ||
On Sun, Sep 19, 2004 at 06:18:56PM +0200, Matthias Pigulla wrote:
> Using str_replace instead of such a preg should be correct:
>
> 1. Every \n will be replaced by \r\n, now matter where it occurs (at the beginning of the input
> or preceding/following another \r or \n).
>
> 2. The only exception (as stated by the assertion) are \n immediately preceded by \r. These
> \r\n will always be \r\r\n after the first step, so \r\r\n => \r\n will remove the extra \r
> introduced. The other way round, you can always be sure that after step one, every
> "\r\r\n" contains an extra "\r", so removing one of them will always correct the
> extra \r introduced in step one and will never remove any \r that is part of the input string.
>
> Was that a clarification or obfuscation? ;)
I think that makes ense to me, although I'm pretty short on time at
the moment, too.
If you can submit a unit test (for the tests/ directory) that passes
under both the old and new code, I'll be happy to apply the change.
--
Jon Parise (jon of php.net) :: The PHP Project (http://www.php.net/)