]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: dedupe_subject: allow "0" as a valid Subject
authorEric Wong <e@yhbt.net>
Sat, 4 Apr 2020 08:03:17 +0000 (08:03 +0000)
committerEric Wong <e@yhbt.net>
Sat, 4 Apr 2020 23:37:15 +0000 (23:37 +0000)
While rare in practice (even by spammers), A single "0" could
theoretically be the entire contents of a Subject line.  So
use the Perl 5.10+ defined-or operator to improve correctness
of subject deduplication.

lib/PublicInbox/View.pm

index 9ef1f68ae914fdbf54ce5f9aa029449917b7a171..f0584cb7f0ee0211f538e4aca55ee9ac328273b9 100644 (file)
@@ -888,20 +888,20 @@ sub missing_thread {
 sub dedupe_subject {
        my ($prev_subj, $subj, $val) = @_;
 
-       my $omit = ''; # '"' denotes identical text omitted
+       my $omit; # '"' denotes identical text omitted
        my (@prev_pop, @curr_pop);
        while (@$prev_subj && @$subj && $subj->[-1] eq $prev_subj->[-1]) {
                push(@prev_pop, pop(@$prev_subj));
                push(@curr_pop, pop(@$subj));
-               $omit ||= $val;
+               $omit //= $val;
        }
        pop @$subj if @$subj && $subj->[-1] =~ /^re:\s*/i;
        if (scalar(@curr_pop) == 1) {
-               $omit = '';
+               $omit = undef;
                push @$prev_subj, @prev_pop;
                push @$subj, @curr_pop;
        }
-       $omit;
+       $omit // '';
 }
 
 sub skel_dump { # walk_thread callback