From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [IPv6:2a01:4f8:1c0c:6b10::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 143BB1F61A for ; Mon, 12 Dec 2022 02:05:30 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.b="mVYp0GQA"; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id AFF507E583; Mon, 12 Dec 2022 02:05:16 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=mVYp0GQA; dkim-atps=neutral Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 8424B7E572 for ; Mon, 12 Dec 2022 02:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=y806SdYTmOUMFBL5t91vI/uLossNb982XLvGLmPWNFI=; b=mVYp0GQAENKusxY5Bed5WUMTfkS7ZCTP6yJwsDvECEJPeBNJ/vTMTWOTGGkL1p+wUuoT ApwlVpn53Eq3JTk+aVphqF1ZnUiqU8OZ33cr3nn4zhZYQiVmSy/1Qv8OuLPprjXuBu7DX4 fv1lv0gfphynxP36FHkc7NI67te+KuyOudaKS4EdiIMDo/PgfYfJ3nqxt/4Kd69J9OpARV 0HL+ypF1oEklO9pts+mZueJzElMotbg3UJQpAsqqoIIMy7NMvUG4qHWB0svaJFq4SG7iO7 ahnZ0lQRXwMEf0U1ZecVkKqzvJd5GJKgvNAOHay9eYAJTkooxYaawf3bF3en/+aA== Received: by filterdrecv-557d69979-cx8s6 with SMTP id filterdrecv-557d69979-cx8s6-1-63968C53-8 2022-12-12 02:05:07.315351506 +0000 UTC m=+2084363.563598785 Received: from herokuapp.com (unknown) by geopod-ismtpd-5-6 (SG) with ESMTP id cfjMdJ78Si6TkMpSBlTRuQ for ; Mon, 12 Dec 2022 02:05:07.211 +0000 (UTC) Date: Mon, 12 Dec 2022 02:05:07 +0000 (UTC) From: "matz (Yukihiro Matsumoto)" Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 19194 X-Redmine-Issue-Author: make_now_just X-Redmine-Sender: matz X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 87614 X-SG-EID: =?us-ascii?Q?SqOeWfVKFgkgw8cVgc6MYslIG5ZBbSbWU3opJ5u4yBsU3yWoizgPd1Pss4ZMTd?= =?us-ascii?Q?OLBRodnvQO26=2FFyqng1x72rdTkbmTHg5l1+yKA9?= =?us-ascii?Q?AQWjb7MO7Vqblyqrxd5Q1AShIWaoJtdEbAQtmeF?= =?us-ascii?Q?Q5hHKKLfODwtm6Jk3ORcltVsLQy7fdOgnGnpNWs?= =?us-ascii?Q?pTMWx9l=2FJaiUX+x1PGJTeLmiDSP3AHRXchul=2FUn?= =?us-ascii?Q?osJVy8+LvNlMyfX81uwkBfJfyw7=2F7n7wc+6u9MT?= =?us-ascii?Q?y75TvubfRKdjIN5hEwwVA=3D=3D?= To: ruby-dev@ml.ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== Message-ID-Hash: RAP6SMWQ6CIMYYUY4JWZIVKA6JBXX7MW X-Message-ID-Hash: RAP6SMWQ6CIMYYUY4JWZIVKA6JBXX7MW X-MailFrom: bounces+313651-12dc-ruby-dev=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: "Ruby developers (Japanese)" Subject: =?utf-8?q?=5Bruby-dev=3A52016=5D_?= [Ruby master Feature#19194] Add Regexp.linear_time? List-Id: "Ruby developers (Japanese)" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Issue #19194 has been updated by matz (Yukihiro Matsumoto). Accepted. Matz. ---------------------------------------- Feature #19194: Add Regexp.linear_time? https://bugs.ruby-lang.org/issues/19194#change-100551 * Author: make_now_just (Hiroya Fujinami) * Status: Open * Priority: Normal ---------------------------------------- I suggest adding a new method named `Regexp.linear_time?` to check if matching against a given regexp can be completed in linear time by the optimization introduced in #19104 (GitHub PR [#6486](https://github.com/ruby/ruby/pull/6486)). This method was discussed in #19104. I'm not sure the name is best. # Example ``` Regexp.linear_time?(/a/) # => true Regexp.linear_time?(/(a|a)*\1/) # => false, because this uses a back-reference. # This can accept a regexp source string and flags like `Regexp.new`. Regexp.linear_time?('a') # => true Regexp.linear_time?('a', Regexp::IGNORECASE) # => true ``` For example, this method is useful for implementing a Rubocop rule to check a regexp is ReDoS safe. # Implementation Implementation is done at GitHub PR [#6901](https://github.com/ruby/ruby/pull/6901). See the details there. -- https://bugs.ruby-lang.org/