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,AWL,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 C46281F453 for ; Fri, 26 Apr 2019 07:48:32 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [RFC] viewdiff: do not break out of DSTATE_CTX on /^$/ Date: Fri, 26 Apr 2019 07:48:32 +0000 Message-Id: <20190426074832.14686-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It seems a common case for mangled patches is editors or MUAs dropping trailing whitespace, and lines matching /^ $/ gets the space dropped to only match /^$/. --- lib/PublicInbox/ViewDiff.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index 0cce952..6b8d943 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -146,7 +146,7 @@ sub flush_diff ($$$) { if ($s =~ /^---$/) { to_state($dst, $state, DSTATE_STAT); $$dst .= $s; - } elsif ($s =~ /^ /) { + } elsif ($s =~ /^ / || ($s =~ /^$/ && $state >= DSTATE_CTX)) { # works for common cases, but not weird/long filenames if ($state == DSTATE_STAT && $s =~ /^ (.+)( +\| .*\z)/s) { -- EW