Re: [RFC] Remove \0 from default trim() character mask
| From: | Larry Garfield | Date: | Tue, 24 Mar 2026 18:48:14 +0000 |
| Subject: | Re: [RFC] Remove \0 from default trim() character mask | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-130435@lists.php.net to get a copy of this message | ||
On Tue, Mar 24, 2026, at 1:29 PM, Levi Morrison wrote:
> On Tue, Mar 24, 2026 at 11:14 AM LamentXU <lamentxu@163.com> wrote:
>>
>> Hi all,
>>
>> I believe the RFC “Don't trim NUL bytes by default” is ready to move to the voting
>> phase. I intend to open the voting period soon (typically 7 days).
>>
>> RFC page: https://wiki.php.net/rfc/dont_trim_nul
>>
>> This RFC proposes to remove \0 (NUL byte) from the default character mask of trim(),
>> ltrim(), and rtrim(), to align with common expectations and avoid unintended trimming of legitimate
>> NUL-containing strings. Please tell me if there are any final comments or concerns. Thanks.
>>
>> Best regards,
>> Weilin Du
>>
>> p.s. Not that sure if this email is going be be sent in the correct thread, so I would post
>> the thread link here if it doesn't
>> https://externals.io/message/130318
>
> I agree that \0 is a control byte and not whitespace, so it probably
> shouldn't be included in any of the trim functions. However, at this
> stage in PHP's lifecycle I am not sure if we should fix it.
>
> There hasn't been much discussion, so dear internals: are simply busy,
> un-opinionated, or what?
No strong feeling on the matter, will probably Abstain. I don't think it's something that
I've ever run into, since I tend to know very well if my strings are bytes or characters and
use them appropriately.
--Larry Garfield