Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129659 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 4EE521A00BC for ; Fri, 19 Dec 2025 15:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1766157035; bh=nwYOLGCL0OhYvaQg1U5izI4TSgpLL0U3RfT5CW+rU2w=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gwvgsZDAMU1E+QzBkV5R3hb1jG43+xcXGTlXDzfo6DdZT8jtJfZ9b1gqJN5tfdHe3 z456VrceOyjEbEmqOhWIZIesYvgFYAfslNtYC+4ph8zdGw8fm5E54cPhVi08TXYAlL l1hGC6JpgHzFdex7yzQY/nu1yVhM2R8Xw1nEMbIuVrci9yNEIsb94tkoDUUA6NSJlT XDP8cU+piDoJFOmcqE1BxOlpe6+t+EJZG/JvAhVuyAPC86Xz0RgBvnhwwI5FIvHiBx +V3xfgi4qObJyvgRes2QsZhCu5HFitOI42pVlHGO7yxdgnk/xDcZhoQb9Px13CHGYf /B86rjbbIdz+g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B36F3180057 for ; Fri, 19 Dec 2025 15:10:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 19 Dec 2025 15:10:31 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-34aa62f9e74so2348758a91.1 for ; Fri, 19 Dec 2025 07:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766157025; x=1766761825; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=F3fXRR1yzFuU0J9zNcr5mVUWa7N/N2JZshCOQ5X+6no=; b=nXcCw9+Byg8B2tEImwrxCJ5+2HWBOkKm8i6RYX8v7oBRcnib5Qx/LTcT+oMvgLVIo9 aXrY31hmuN1ctYj+CivpH5UjCNj9yMF+nrOTqJMgkT8wn3XXcrsHM7u4XlPSbxsPa0A2 e7bJCK9g8hMDXqW0whGYbcEgh650f/cSDBkOOvIXzm/zbGaNnwSn/QBy8S/pyA/C/IPy dmxKmQqV2LtfOEfCQCUIiWFTwVpJie10+0fOjRsz0bLTLj89uFObHqJDZaHA6jnaCwLd q4/d8bBmk0nHQJ1bIyaUeOgAet0AkrU/Euk6qIkcKCi3H8DE3MfFf8a8nqqCD8xasU0S FalQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766157025; x=1766761825; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=F3fXRR1yzFuU0J9zNcr5mVUWa7N/N2JZshCOQ5X+6no=; b=p5j0Xo7PNN6Leng9rkKuA9HJIxAE2c2tE5h7q+wpBmCc4p7ycdg3aUK40MbNsoxBn7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ed59e1d1-34e921221aemr2485213a91.5.1766157025198; Fri, 19 Dec 2025 07:10:25 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <23051439-6f0d-4175-b632-3b943582bfe0@beccati.com> In-Reply-To: Date: Fri, 19 Dec 2025 16:09:32 +0100 X-Gm-Features: AQt7F2pzbUUsUXMzGxtukkZnnkIXbNVJ5kHpmnh3JYJfree5l5IO0E7ByX11hdM Message-ID: Subject: Re: [PHP-DEV] [RFC] New function mysqli_quote_string To: Kamil Tekiela Cc: Matteo Beccati , PHP internals Content-Type: multipart/alternative; boundary="0000000000001ac58e06464f7a5f" From: divinity76@gmail.com (Hans Henrik Bergan) --0000000000001ac58e06464f7a5f Content-Type: text/plain; charset="UTF-8" On Fri, 19 Dec 2025 at 15:26, Kamil Tekiela wrote: > On Fri, 19 Dec 2025 at 13:52, Matteo Beccati wrote: > > > > Hi Kamil, > > > > > > Il 18/12/2025 22:03, Kamil Tekiela ha scritto: > > > Hello, > > > > > > I would like to open a discussion about adding a new function to PHP > > > > > > https://wiki.php.net/rfc/mysqli_quote_string > > > > > > Would you support such an addition? > > > > I agree with you and I prefer PDO::quote()'s behaviour over the "old" > > non-pdo quote functions. > > > > However, I also think that manually interpolating parameters is not a > > best practice that we should encourage: query parameters are the a much > > better defence against SQL injections. > > > > Also I'm afraid that offering two alternatives would increase the > > confusion, especially if this new function is added only to mysqli and > > not other prominent database extensions. > > > > > > Cheers > > -- > > Matteo > > Hi Mateo, > > The new function isn't meant to encourage this practice. My RFC > acknowledges that query parameters are the best, but unfortunately, > manual escaping is a must for certain applications. > > What other extensions do you have in mind? PDO already has it, so does > PostgreSQL with pg_escape_literal(). Every extension is different and > they never have the exact same functions. In fact, what I am proposing > is to bring mysqli in line with other extensions which already have > it. > > The confusion it's going to cause is minimal. The behaviour is exactly > the same as the old function, just that the quotation marks are added > automatically. It's not rocket science. > > Regards, > Kamil > btw pg_escape_literal is mis-named. it does not escape - it quotes. And there is an important difference between escaping and quoting, at least for SQLite, it is impossible to make a binary-safe escape() function, but it's fully possible to make a binary-safe quote() function (see https://github.com/php/php-src/pull/13972 ) IMO pg_escape_literal should be renamed pg_quote_literal. --0000000000001ac58e06464f7a5f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Fri, 19 Dec = 2025 at 15:26, Kamil Tekiela <te= kiela246@gmail.com> wrote:
On Fri, 19 Dec 2025 at 13:52, Matteo Beccati <php@beccati.com> wrote= :
>
> Hi Kamil,
>
>
> Il 18/12/2025 22:03, Kamil Tekiela ha scritto:
> > Hello,
> >
> > I would like to open a discussion about adding a new function to = PHP
> >
> > https://wiki.php.net/rfc/mysqli_quote_string
> >
> > Would you support such an addition?
>
> I agree with you and I prefer PDO::quote()'s behaviour over the &q= uot;old"
> non-pdo quote functions.
>
> However, I also think that manually interpolating parameters is not a<= br> > best practice that we should encourage: query parameters are the a muc= h
> better defence against SQL injections.
>
> Also I'm afraid that offering two alternatives would increase the<= br> > confusion, especially if this new function is added only to mysqli and=
> not other prominent database extensions.
>
>
> Cheers
> --
> Matteo

Hi Mateo,

The new function isn't meant to encourage this practice. My RFC
acknowledges that query parameters are the best, but unfortunately,
manual escaping is a must for certain applications.

What other extensions do you have in mind? PDO already has it, so does
PostgreSQL with pg_escape_literal(). Every extension is different and
they never have the exact same functions. In fact, what I am proposing
is to bring mysqli in line with other extensions which already have
it.

The confusion it's going to cause is minimal. The behaviour is exactly<= br> the same as the old function, just that the quotation marks are added
automatically. It's not rocket science.

Regards,
Kamil

--0000000000001ac58e06464f7a5f--