RSS

(root)/bugzilla/extensions/securemail/4.0 : 19 : Extension.pm

To get this branch, use:
bzr branch /bugzilla/extensions/securemail/4.0

« back to all changes in this revision

Viewing changes to Extension.pm

Dave Lawrence
2012-04-05 09:58:31
Revision ID: dlawrence@mozilla.com-20120405165831-fqb43ti1fdd8xqrr
Merged with bmo/4.0/extensions/SecureMail

Show diffs side-by-side

added added

removed removed

26
26
use Bugzilla::Group;
27
27
use Bugzilla::Object;
28
28
use Bugzilla::User;
29
 
use Bugzilla::Util qw(correct_urlbase trim trick_taint);
 
29
use Bugzilla::Util qw(correct_urlbase trim trick_taint is_7bit_clean);
30
30
use Bugzilla::Error;
31
31
use Bugzilla::Mailer;
32
32
 
227
227
        if ($is_bugmail) {
228
228
            # This is also a bit of a hack, but there's no header with the 
229
229
            # bug ID in. So we take the first number in the subject.
230
 
            my ($bug_id) = ($email->header('Subject') =~ /^[^\d]+(\d+)/);
 
230
            my ($bug_id) = ($email->header('Subject') =~ /\[\D+(\d+)\]/);
231
231
            my $bug = new Bugzilla::Bug($bug_id);
232
 
            if ($bug && !grep($_->{secure_mail}, @{ $bug->groups_in })) {
 
232
            if ($bug 
 
233
                && !$bug->{'error'} 
 
234
                && !grep($_->{secure_mail}, @{ $bug->groups_in })) 
 
235
            {
233
236
                $make_secure = 0;
234
237
            }
235
238
        }
262
265
    my ($email, $key, $sanitise_subject) = @_;
263
266
 
264
267
    my $subject = $email->header('Subject');
265
 
    my ($bug_id) = $subject =~ /^\D+(\d+)/;
 
268
    my ($bug_id) = $subject =~ /\[\D+(\d+)\]/;
266
269
 
267
270
    my $key_type = 0;
268
271
    if ($key && $key =~ /PUBLIC KEY/) {
275
278
    if ($key_type && $sanitise_subject) {
276
279
        # Subject gets placed in the body so it can still be read
277
280
        my $body = $email->body_str;
 
281
        if (!is_7bit_clean($subject)) {
 
282
            $email->encoding_set('quoted-printable');
 
283
        }
278
284
        $body = "Subject: $subject\015\012\015\012" . $body;
279
285
        $email->body_str_set($body);
280
286
    }
350
356
        # This is designed to still work if the admin changes the word
351
357
        # 'bug' to something else. However, it could break if they change
352
358
        # the format of the subject line in another way.
353
 
        $subject =~ s/($bug_id\])\s+(.*)$/$1 (Secure bug updated)/;
 
359
        $subject =~ s/($bug_id\])\s+(.*)$/$1 (Secure bug $bug_id updated)/;
354
360
        $email->header_set('Subject', $subject);
355
361
    }
356
362
}

Loggerhead 1.18.1 is a web-based interface for Bazaar branches