From bbfa42a9ea55b7057c7a6b632f090763c9e7c655 Mon Sep 17 00:00:00 2001
From: Eric Wong <e@80x24.org>
Date: Tue, 4 Jun 2019 08:30:55 +0000
Subject: [PATCH] solver|viewdiff: restrict digit matches to ASCII

git would not generate non-ASCII digits to describe
hunk offsets, so don't waste more time than necessary
to make sense of non-ASCII digit chars for line offsets.
---
 lib/PublicInbox/SolverGit.pm | 2 +-
 lib/PublicInbox/ViewDiff.pm  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index 3841c567..81f99025 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -206,7 +206,7 @@ sub find_extract_diff ($$$) {
 	}
 
 	my $msgs = $srch->query($q, { relevance => 1 });
-	my $re = qr/\Aindex ($pre[a-f0-9]*)\.\.($post[a-f0-9]*)(?: (\d+))?/;
+	my $re = qr/\Aindex ($pre[a-f0-9]*)\.\.($post[a-f0-9]*)(?: ([0-9]+))?/;
 
 	my $di;
 	foreach my $smsg (@$msgs) {
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm
index 411ed2bb..b7dab819 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -55,12 +55,12 @@ sub diff_hunk ($$$$) {
 	(defined($spfx) && defined($oid_a) && defined($oid_b)) or
 		return "@@ $ca $cb @@";
 
-	my ($n) = ($ca =~ /^-(\d+)/);
+	my ($n) = ($ca =~ /^-([0-9]+)/);
 	$n = defined($n) ? do { ++$n; "#n$n" } : '';
 
 	my $rv = qq(@@ <a\nhref="$spfx$oid_a/s/$dctx->{Q}$n">$ca</a>);
 
-	($n) = ($cb =~ /^\+(\d+)/);
+	($n) = ($cb =~ /^\+([0-9]+)/);
 	$n = defined($n) ? do { ++$n; "#n$n" } : '';
 
 	$rv .= qq( <a\nhref="$spfx$oid_b/s/$dctx->{Q}$n">$cb</a> @@);
-- 
2.50.0