Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67211 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2179 invoked from network); 30 Apr 2013 11:30:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2013 11:30:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.178 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.220.178 mail-vc0-f178.google.com Received: from [209.85.220.178] ([209.85.220.178:65183] helo=mail-vc0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/52-18873-64BAF715 for ; Tue, 30 Apr 2013 07:30:14 -0400 Received: by mail-vc0-f178.google.com with SMTP id ha11so309880vcb.9 for ; Tue, 30 Apr 2013 04:30:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=PKxmi+wTUzv9os6UdvqE25kd0BLBsAXB18NDeQvv3O8=; b=C9VTJqEuP+hu+sE7HNEXhve/UDRQIfk/FU4DqTQBKgVQ4sPifxw9ao7BmY5OEoK2F+ xbD9iyG7DVBayUGj3YggyPI3z+sMQrxl/TJjYyjSONeLfCttPN7AW6sXfbaZx98tkKkV vitSBBCeOCoPwfv94HUTN0Mx0GczB8bb5+zpoR7ZIPHJGo4+9u915mhOLZbjG+Vq7692 e9zO2aq4nvM+eUBIcbb9ZBnRjOq5Eke99tQJdDe/RwS+1YgCCb0k4yf7A/+n/p6RRq43 2Umz/cTNDaS9uAXAZkEIwBgQjCcyu+bNSuo8JixrnirFdGpvjLApNQUQ4a7Wu19IwgAM 5o4w== MIME-Version: 1.0 X-Received: by 10.52.232.196 with SMTP id tq4mr29291664vdc.15.1367321411863; Tue, 30 Apr 2013 04:30:11 -0700 (PDT) Received: by 10.58.156.103 with HTTP; Tue, 30 Apr 2013 04:30:11 -0700 (PDT) In-Reply-To: References: Date: Tue, 30 Apr 2013 07:30:11 -0400 Message-ID: To: ALeX Cc: PHP Internals Content-Type: multipart/alternative; boundary=089e01184abe0c4a9c04db9253ee Subject: Re: [PHP-DEV] Re: [lists.php] [PHP-DEV] [PROPOSAL]Add second to callback of preg_replace_callback From: ircmaxell@gmail.com (Anthony Ferrara) --089e01184abe0c4a9c04db9253ee Content-Type: text/plain; charset=ISO-8859-1 ALeX, On Mon, Apr 29, 2013 at 5:53 PM, ALeX wrote: > what about patch preg_replace to accept callbacks? > > example: > preg_replace(array( > "/pattern1(.*)/", > "/pattern2(.*)/" > ), > array( > function ($pat) { ... } , > "replace" > ) > , ... ); > > There are some weird questions that come up with that. For example, if an array item is an object that implements both __invoke() and __toString(), which should be fired? Is it a string? Or a callback? What if I pass a literal string "strlen", is that a callback, or a replacement? The point is not that it's a bad idea and that we can't make a distinction, but more that there are pretty severe edge-cases that we'd have to work around, and if we don't get it right security could suffer significantly (especially when user-input is allowed to be a replacement)... Anthony --089e01184abe0c4a9c04db9253ee--