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=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 0E4AE1F463; Thu, 2 Jan 2020 19:04:49 +0000 (UTC) Date: Thu, 2 Jan 2020 19:04:49 +0000 From: Eric Wong To: meta@public-inbox.org Subject: Re: [PATCH 2/3] solver: extract_diff: deal with missing "diff --git" line Message-ID: <20200102190448.GA19165@dcvr> References: <20200102092459.17612-1-e@80x24.org> <20200102092459.17612-3-e@80x24.org> <20200102093635.GA11425@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200102093635.GA11425@dcvr> List-Id: Eric Wong wrote: > Eric Wong wrote: > > -my %bad_component = map { $_ => 1 } ('', '.', '..'); > > > > > + # get rid of path-traversal attempts and junk patches: > > + # it's junk at best, an attack attempt at worse: > > + state %bad_component = map { $_ => 1 } ('', '.', '..'); > > Nope, that fails on Perl 5.24.1. > > "Initialization of state variables in list context currently forbidden" > > :< Otherwise, "state" is a nice 5.10.x feature. The following is a simple fix which preserves compatibility with older Perls while keeping the variable contained, will squash: diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index ef76d706..ade94bd3 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -170,8 +170,8 @@ sub extract_diff ($$) { # get rid of path-traversal attempts and junk patches: # it's junk at best, an attack attempt at worse: - state %bad_component = map { $_ => 1 } ('', '.', '..'); - foreach (@a, @b) { return if $bad_component{$_} } + state $bad_component = { map { $_ => 1 } ('', '.', '..') }; + foreach (@a, @b) { return if $bad_component->{$_} } $di->{path_a} = join('/', @a); $di->{path_b} = join('/', @b);