Re: [RFC] Remove \0 from default trim() character mask

From: Date: Wed, 25 Mar 2026 19:20:11 +0000
Subject: Re: [RFC] Remove \0 from default trim() character mask
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-130456@lists.php.net to get a copy of this message
On Sun, Mar 15, 2026 at 1:24 AM LamentXU <lamentxu@163.com> wrote: > I am sending this to introduce my new RFC: https://wiki.php.net/RFC/dont_trim_NUL > I'm not a fan of this for the reasons that several others have already stated. While \0 may not be technically whitespace, you have 30 years of scripts expecting it to be trimmed and undoing that potentially (though perhaps not actually) opens up new security vulnerability for dubious gain. I hope nobody is depending on this to remove *all* null bytes, because of course it won't, but I fail to see how a text oriented function (the notion of whitespace makes this not binary oriented) should be in favor of preserving nulls under any circumstance. If anything functions like this which are specifically text oriented should (perhaps, but for performance and historical raisins probably not) be elevated to throw on discovering null bytes anywhere in the string. -Sara

« previous php.internals (#130456) next »