This file is indexed.

/usr/share/quilt/scripts/edmail is in quilt 0.61-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#! /usr/bin/perl -w

# RFCs important for this script:
#
# RFC 2822 - Internet Message Format
# RFC 2047 - MIME (Multipurpose Internet Mail Extensions) Part Three:
#            Message Header Extensions for Non-ASCII Text

use Getopt::Long;
use strict;

# This ugly trick lets the script work even if gettext support is missing.
# We did so because Locale::gettext doesn't ship with the standard perl
# distribution.
BEGIN {
    if (eval { require Locale::gettext }) {
	import Locale::gettext;
	require POSIX;
	import POSIX, qw(setlocale);
    } else {
	eval '
	    use constant LC_MESSAGES => 0;
	    sub setlocale($$) { }
	    sub bindtextdomain($$) { }
	    sub textdomain($) { }
	    sub gettext($) { shift }
	'
    }
}

setlocale(LC_MESSAGES, "");
bindtextdomain("quilt", "/usr/share/locale");
textdomain("quilt");

sub _($) {
    return gettext(shift);
}

my $special = '()<>\[\]:;@\\,"';  # special characters
my $special_dot = "$special.";  # special characters + dot

sub check_recipient($);

my (%append_name, %append_value, $remove_empty_headers, %remove_header,
    %extract_recipients_from, %replace_name, %replace_value, $charset);
GetOptions('add-recipient=s%' =>
    sub {
	$append_name{lc $_[1]} = $_[1];
	$append_value{lc $_[1]} .= ",\n " . $_[2];
    },
    'add-good-recipient=s%' =>
    sub {
	eval { check_recipient($_[2]) };
	if ($@) {
		chomp $@;
		print STDERR "$@; skipping\n";
	} else {
		$append_name{lc $_[1]} = $_[1];
		$append_value{lc $_[1]} .= ",\n " . $_[2];
	}
    },
    'remove-header=s' => sub { $remove_header{lc $_[1]}++ },
    'remove-empty-headers' => \$remove_empty_headers,
    'replace-header=s%' =>
    sub {
	$replace_name{lc $_[1]} = $_[1];
	$replace_value{lc $_[1]} = $_[2];
    },
    'extract-recipients=s' => sub { $extract_recipients_from{lc $_[1]} = 1 },
    'charset=s' => \$charset)
    or exit 1;
my %recipient_headers = map {lc $_ => 1} (@ARGV, keys %append_name);

sub encode_header($) {
    my ($word) = @_;
    $word =~ s{[^\t\41-\76\100-\176]}{sprintf "=%02X", ord($&)}ge;
    return "=?$charset?q?$word?=";
}

# Check for a valid display name
sub check_display_name($) {
    my ($display) = @_;

    if ($display =~ /^"((?:[^"\\]|\\[^\n\r])*)"/) {
	my $quoted = $1;
	if ($quoted =~ /[^\t\40-\176]/) {
	    $display = $quoted;
	    $display =~ s/\\//;
	    return encode_header($display);
	}
    } else {
	local $_ = $display;
	# The value is not (properly) quoted. Check for invalid characters.
	while (/\(/ or /\)/) {
	    die sprintf(
_("Display name `%s' contains unpaired parentheses\n"), $display)
		unless s/\(([^()]*)\)/$1/;
	}
	if ($display =~ /[^\t\40-\176]/ || $display =~ /[$special_dot]/) {
	    if ($display =~ /[^\1-\10\13\14\16-\37\40\41\43-\133\135-\177]/) {
		return encode_header($display);
	    } elsif ($display =~ /[$special_dot]/) {
		return "\"$display\"";
	    }
	}
    }
    return $display;
}

# Check for a valid delivery address
sub check_delivery_address($) {
    my ($deliver) = @_;

    die sprintf(_("Delivery address `%s' is invalid\n"), $deliver)
	if $deliver =~ /[ \t]/ or
	   $deliver =~ /[^ \t\40-\176]/ or
	   $deliver !~ /^[^$special]+@(\[?)[^$special_dot]+(?:\.[^$special_dot]+)*(\]?)$/ or
	   (!$1) != (!$2);
    return $deliver;
}

sub check_recipient($) {
    my ($recipient) = @_;

    if ($recipient =~ /^(.*?)\s*<(.+)>$/) {
	my $deliver = check_delivery_address($2);
	return ( check_display_name($1) . " <" . $deliver . ">", $deliver );
    } elsif ($recipient =~ /^(\S*)\s*\((.*)\)$/) {
	my $deliver = check_delivery_address($1);
	return ( $deliver . " (" . check_display_name($2) . ")", $deliver );
    } else {
	my $deliver = check_delivery_address($recipient);
	return ( $deliver, $deliver );
    }
}

sub split_recipients($) {
    my ($recipients) = @_;
    my @list = ();

    while ($recipients !~ /^\s*$/) {
	my $recipient;
	if ($recipients =~ s/^\s*,?\s*((?:"(?:[^"]+)"|[^",])*)//) {
	    $recipient = $1;
	} else {
	    $recipient = $recipients;
	    $recipients = "";
	}
	$recipient =~ s/\s*$//;
	push @list, $recipient;
    }
    return @list;
}

my %recipients;
sub process_header($) {
    local ($_) = @_;
    my ($name, $value);

    return unless defined $_;
    unless (($name, $value) = /^([\41-\176]+):\s*(.*)/s) {
	print;
	return
    }
    if (%extract_recipients_from) {
	if (exists $extract_recipients_from{lc $name}) {
	    $value =~ s/^\s*//;  $value =~ s/\s*$//;
	    foreach my $recipient (split_recipients($value)) {
		    my $deliver;
		    ($recipient, $deliver) = check_recipient($recipient);
		    print "$deliver\n";
	    }
	}
	return;
    }
    return if exists $remove_header{lc $name};
    if (exists $replace_name{lc $name}) {
	    if (exists $replace_value{lc $name}) {
		print "$replace_name{lc $name}: $replace_value{lc $name}\n"; 
		delete $replace_value{lc $name};
	    }
	    return;
    }
    if (exists $recipient_headers{lc $1}) {
	if (exists $append_name{lc $name}) {
	    $value .= $append_value{lc $name};
	    delete $append_name{lc $name};
	}
	my @recipients;
	# This is a recipients field. Split out all the recipients and
	# check the addresses. Suppress duplicate recipients.
	foreach my $recipient (split_recipients($value)) {
	    my $deliver;
	    ($recipient, $deliver) = check_recipient($recipient);
	    unless (exists $recipients{$deliver}) {
		push @recipients, $recipient;
		$recipients{$deliver} = $deliver;
	    }
	}
	print "$name: ", join(",\n ", @recipients), "\n"
	    if @recipients || !$remove_empty_headers;
    } else {
	    print if $value ne "" || !$remove_empty_headers;
    }
}

my $header;
while (<STDIN>) {
    last if (/^$/);
    if (/^\S/) {
	process_header $header;
	undef $header;
    }
    $header .= $_;
}
process_header $header;
foreach my $name (keys %append_name) {
    process_header $append_name{$name} . ': ' . $append_value{$name};
}
unless (%extract_recipients_from) {
    # Copy the message body to standard output
    # FIXME check for 7-bit clean, else assume $charset
    # FIXME if UTF-8, check for invalid characters!
    # FIXME must make sure that all messages are written in
    #       either 7-bit or $charset => mbox !!!

    # Content-Transfer-Encoding: 7bit
    # Content-Transfer-Encoding: 8bit
    # Content-Type: text/plain; charset=ISO-8859-15
    # Content-Type: text/plain; charset=UTF-8
    undef $/;
    print "\n", <STDIN>;
}