Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128771 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 CE91C1A00BC for ; Fri, 3 Oct 2025 15:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1759503655; bh=KcgjglEhJ01VwLLluayhFCQHGW3vrSCMp3KVEUy+rdc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kZw785TwNQwl3/bRKSlIii9rHKxkCs2XHXJeJrjEmiCNdHcLvWFracIj+76YSM1v8 aV6B0H1t3mIfbxlTQtaq2bqKYWf4qHqXCd/Ij7Ln9oAOXujA72NEou89vgbxZN8KiE cDA9I1CejppHRHMBJ1LJyO84sJpZSOzuOunx15I7SDNyX+knl9ch+FLrgnKH+poZ6k 6mEp2f6kXiQYE0cJR9Pz1P4L/REocHXw3Dv/RfLGv7+dIGTWE0DV6iv6tVxKELysqk s6KRD3EUc0JyHo0Fd3EL8hj7sqX6rb+dvecPQjbU8YYv8f7DAZN77Ff/arCU6PL8B4 /9IPI3Mnf3Q0w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6B0751801D4 for ; Fri, 3 Oct 2025 15:00:54 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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, 3 Oct 2025 15:00:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1759503730; bh=Lsp31smegVIbQz+ejSTI1ARh9LEGZCc+V7F9WRP2LG0=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=UtPnXhSfmZBlTrozYR/g42eRnYx7FOwFT3wPRi96OwVQb2jU/bDK8uGKEjicuKw03 f3qza2c35nKDG3/F9I4Bq5yk119v2gFoU69oV9LGrLzmlzi6K/h8zdsVO5ttAx+3Xp 70mmITcUT1F2wTBLomKfdTi5oCgGe0xJ0utUzkgpqs2Hlzg6hd9wyDg27E11tzBwrS 2Tp45g51xlbWNMX9XJVbVOfSl5w+1EeLXtnPLl8v/t1yZfAQFSAqJbi53yGmcU//hC fxnwSkeQMf5Z57GoyDa17MyEwz2klhCmu5JszCeJQVUk5loJZQnpW9kKsnlnkJNeM5 M5vG0r+h7jx1w== Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 03 Oct 2025 17:02:10 +0200 To: Ayesh Karunaratne Cc: Alexandre Daubois , Juliette Reinders Folmer , internals@lists.php.net Subject: Re: [PHP-DEV] [DISCUSSION] Validating regex pattern In-Reply-To: References: <68DD64BE.5080308@adviesenzo.nl> Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-10-02 13:03, schrieb Ayesh Karunaratne: > I completely agree with this and the previous reply from Juliette. I also fully agree with Juliette: This is something that needs to be done in ext/pcre. > A `PREG_THROW_ON_ERROR` flag would be the best of both worlds: > > - Provides a nice safe-guard against potentially invalid regexps and > surfaces them up as an exception. > - Provides validation functionality with engine-provided error > messages. > - We do not need to keep up with the regex engines because validation > is done by the engine. > - Works similar to the `JSON_THROW_ON_ERROR` flag. I however don't think that PREG_THROW_ON_ERROR is the best solution here. A flag that effectively *always* needs to be passed is not good API design and functions like `preg_replace()` don't currently support flags. While it would definitely increase the scope of an RFC, I second Thomas' notion of providing a new (object-oriented) pcre API that would also allow for passing modifiers independently of the expression itself, avoiding the need for delimiters (and escaping them when dynamically constructing a regex). Best regards Tim Düsterhus