This file is indexed.

/usr/share/perl5/ClamTk/Submit.pm is in clamtk 4.45-1.

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

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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# ClamTk, copyright (C) 2004-2013 Dave M
#
# This file is part of ClamTk (http://clamtk.sourceforge.net).
#
# ClamTk is free software; you can redistribute it and/or modify it
# under the terms of either:
#
# a) the GNU General Public License as published by the Free Software
# Foundation; either version 1, or (at your option) any later version, or
#
# b) the "Artistic License".
package ClamTk::Submit;
# This file probably needs some work.  Or I need to understand encoding
# better.  It's like one big hackjob.

# use strict;
# use warnings FATAL => 'all';
$| = 1;
use encoding 'utf8';

use LWP::UserAgent;
use Encode 'encode';
use Date::Calc 'Delta_Days';
use File::Basename 'basename';

use Glib 'TRUE', 'FALSE';

use Locale::gettext;
use POSIX 'locale_h', 'strftime';

# Highlights certain fields required by clamav.net's form:
my $required_field = "<span foreground = 'red'>*</span>";

# File chosen by the user for analysis:
my $chosen = '';

# Url we post to
my $url = 'http://cgi.clamav.net/';

# Main window:
my $sub_window;
my ( $name_entry,  $email_entry,  $desc_entry );
my ( $name_desc,   $email_desc );
my ( $name_string, $email_string, $file_string );
my ( $new_btn,     $close_btn,    $file_btn );
my ( $file_status, $long_string, $bottombar, $statusbar );

# This file stores the number of times the
# user has submitted a sample each day.
my ($file_path) = ClamTk::App->get_path('submit') . '/times';

sub analysis {
    # These are the main $window's x/y coordinates.
    # Seems to work intermittently, and possibly
    # less expensive than sending $window itself.
    # The ->move below shifts it to those coordinates.
    my ( undef, $x, $y ) = @_;
    $sub_window = Gtk2::Dialog->new();
    $sub_window->signal_connect( close => sub { $sub_window->destroy } );
    $sub_window->set_title( gettext('Submit a file for analysis') );
    if ( -e '/usr/share/pixmaps/clamtk.png' ) {
        $sub_window->set_default_icon_from_file(
            '/usr/share/pixmaps/clamtk.png');
    } elsif ( -e '/usr/share/pixmaps/clamtk.xpm' ) {
        $sub_window->set_default_icon_from_file(
            '/usr/share/pixmaps/clamtk.xpm');
    }
    $sub_window->move( $x, $y );

    my $vbox = Gtk2::VBox->new( FALSE, 1 );
    $sub_window->get_content_area()->add($vbox);

    my $prelude = create_view();
    $vbox->pack_start( $prelude, TRUE, TRUE, 1 );

    my $table = Gtk2::Table->new( 3, 7, FALSE );
    $vbox->pack_start( $table, FALSE, FALSE, 0 );
    $table->set_row_spacings(5);
    $table->set_border_width(2);

    $name_desc = Gtk2::Label->new;
    $table->attach_defaults( $name_desc, 0, 1, 0, 1 );
    $name_string = gettext('Name');
    $name_desc->set_markup($name_string);
    my $n_filled_field = Gtk2::Label->new;
    $n_filled_field->set_markup($required_field);
    $table->attach_defaults( $n_filled_field, 1, 2, 0, 1 );
    $name_entry = Gtk2::Entry->new_with_max_length(40);
    $table->attach_defaults( $name_entry, 2, 3, 0, 1 );
    $name_entry->signal_connect(
        'insert-text' => sub {
            my ( $widget, $string, $position ) = @_;
            if ( $string !~ m#[\w0-9\.\-\_\s]# ) {
                $name_entry->signal_stop_emission_by_name('insert-text');
            }
            return;
        } );

    $email_desc = Gtk2::Label->new;
    $table->attach_defaults( $email_desc, 0, 1, 1, 2 );
    $email_string = gettext('Email');
    $email_desc->set_markup($email_string);
    my $e_filled_field = Gtk2::Label->new;
    $e_filled_field->set_markup($required_field);
    $table->attach_defaults( $e_filled_field, 1, 2, 1, 2 );
    $email_entry = Gtk2::Entry->new_with_max_length(80);
    $table->attach_defaults( $email_entry, 2, 3, 1, 2 );
    $email_entry->signal_connect(
        'insert-text' => sub {
            my ( $widget, $string, $position ) = @_;

            if ( $string !~ m#[\w0-9\.\@\-\_]# ) {
                $email_entry->signal_stop_emission_by_name('insert-text');
            }
            return;
        } );

    # The default string for the area holding the filename
    $file_string = gettext('No file selected');
    # This shades it a little
    $long_string = "<span foreground='#CCCCCC'>$file_string</span>";

    my $file_text = gettext('Select File');
    $file_btn = Gtk2::Button->new($file_text);
    $table->attach_defaults( $file_btn, 0, 1, 2, 3 );
    $file_btn->signal_connect(
        clicked => sub {
            $chosen = select_file();
            if ( $chosen && -e $chosen && -s $chosen ) {
                # The following are things I've seen in filenames
                # for malware: [a-z], [0-9], spaces, literal dots,
                # parens, hyphens, pound (# - seen in UPS crapware),
                # literal question marks, equals (exploit kit stuff)
                if ( $chosen =~ m!^([#\w\s/\.\(\)\?\-=]+)$! ) {
                    $file_status->set_text( basename($1) );
                } else {
                    $file_status->set_markup(
                        qq(<span underline="error" underline_color="red">$file_string</span>)
                        );
                    field_loop();
                    $file_status->set_markup($long_string);
                    $file_btn->grab_focus();
                }
            }
        } );
    my $f_filled_field = Gtk2::Label->new;
    $f_filled_field->set_markup($required_field);
    $table->attach_defaults( $f_filled_field, 1, 2, 2, 3 );
    $file_status = Gtk2::Label->new();
    $table->attach_defaults( $file_status, 2, 3, 2, 3 );
    $file_status->set_markup($long_string);
    $file_status->set_ellipsize('middle');

    # The file can be categorized as either
    # new malware (undetected) or a false positive.
    # New malware is the default option.
    my $sampleis_text = Gtk2::Label->new( gettext('The attached file is') );
    $table->attach_defaults( $sampleis_text, 0, 1, 3, 4 );
    my $bb = Gtk2::HButtonBox->new();
    $bb->set_layout('end');
    $table->attach_defaults( $bb, 1, 3, 3, 4 );
    $new_btn = Gtk2::RadioButton->new( undef, gettext('New malware') );
    my $false_pos =
        Gtk2::RadioButton->new( $new_btn, gettext('A false positive') );
    $bb->add($new_btn);
    $bb->add($false_pos);

    # Optional description of the file being uploaded
    my $desc_text  = gettext('Description');
    my $desc_label = Gtk2::Label->new($desc_text);
    $table->attach_defaults( $desc_label, 0, 1, 4, 5 );
    $desc_entry = Gtk2::Entry->new_with_max_length(50);
    $table->attach_defaults( $desc_entry, 1, 3, 4, 5 );
    $desc_entry->signal_connect(
        'insert-text' => sub {
            my ( $widget, $string, $position ) = @_;

            if ( $string !~ m#[\w0-9\.\@\-\s]# ) {
                $desc_entry->signal_stop_emission_by_name('insert-text');
            }
            return;
        } );

    $statusbar = Gtk2::Label->new();
    $table->attach_defaults( $statusbar, 0, 3, 5, 6 );

    $bottombar = Gtk2::Toolbar->new();
    $table->attach_defaults( $bottombar, 0, 3, 6, 7 );
    $bottombar->set_style('both-horiz');

    my $ssep = Gtk2::SeparatorToolItem->new;
    $ssep->set_draw(FALSE);
    $ssep->set_expand(TRUE);
    $bottombar->insert( $ssep, -1 );

    my $clear_btn = Gtk2::ToolButton->new_from_stock('gtk-clear');
    $clear_btn->set_is_important(TRUE);
    $bottombar->insert( $clear_btn, -1 );
    $clear_btn->signal_connect( clicked => \&clear );
    $clear_btn->grab_focus();

    $bottombar->insert( Gtk2::SeparatorToolItem->new, -1 );

    my $quit_btn = Gtk2::ToolButton->new_from_stock('gtk-close');
    $quit_btn->set_is_important(TRUE);
    $bottombar->insert( $quit_btn, -1 );
    $quit_btn->signal_connect( clicked => sub { $sub_window->destroy } );

    $bottombar->insert( Gtk2::SeparatorToolItem->new, -1 );

    my $forward_btn = Gtk2::ToolButton->new_from_stock('gtk-go-forward');
    $forward_btn->set_is_important(TRUE);
    $bottombar->insert( $forward_btn, -1 );
    $forward_btn->signal_connect( clicked => \&double_check );

    $close_btn = Gtk2::ToolButton->new_from_stock('gtk-close');
    $close_btn->set_is_important(TRUE);
    $vbox->pack_start( $close_btn, FALSE, FALSE, 5 );
    $close_btn->signal_connect( clicked => sub { $sub_window->destroy } );

    $sub_window->show_all();
    $close_btn->hide();
    $name_entry->grab_focus;

    # Check if user has already submitted two for the day;
    # if so, give popup window and return
    my $amount = get_amount();
    if ( $amount >= 2 ) {
        my $message =
            gettext('Please do not submit more than two files per day.');
        my $dialog =
            Gtk2::MessageDialog->new_with_markup( $sub_window,
            [qw(modal destroy-with-parent)],
            'info', 'ok', $message );
        $dialog->run;
        $sub_window->destroy();
    }
}

sub clear {
    $name_entry->set_text('');
    $email_entry->set_text('');
    $file_status->set_markup($long_string);
    $desc_entry->set_text('');
    $name_entry->grab_focus();
    return;
}

sub select_file {
    my $picker = Gtk2::FileChooserDialog->new(
        gettext('Select File'), $sub_window, 'open',
        'gtk-cancel' => 'cancel',
        'gtk-ok'     => 'ok',
        );
    if ( 'ok' eq $picker->run() ) {
        my $gotone = $picker->get_filename();
        $picker->destroy;
        return $gotone;
    } else {
        $picker->destroy;
        return;
    }
}

sub double_check {
    unless ( length( $name_entry->get_text )
        && length( $email_entry->get_text )
        && ( $chosen && -e $chosen )
        && valid_email( $email_entry->get_text ) ) {
        field_check() || return;
    }

    my $message = gettext('You are about to submit a file for analysis.');
    $message .= "\n\n";
    $message .= gettext('Press OK to continue, or Cancel to go back.');

    my $dialog = Gtk2::MessageDialog->new( $sub_window, 'destroy-with-parent',
        'info', 'ok-cancel', $message );
    if ( 'ok' eq $dialog->run() ) {
        $dialog->destroy();
        submit();
    } else {
        $dialog->destroy();
    }
    return;
}

sub submit {
    # Don't need buttons to click anymore.
    # If we manipulate the buttons this way, we can
    # avoid them having to be global variables.
    my @bchild = $bottombar->get_children;
    for my $l (@bchild) {
        if ( $l->isa('Gtk2::Button') ) {
            $l->set_sensitive(FALSE);
        }
    }

    # Our $ua
    my $ua = LWP::UserAgent->new;

    # Custom useragent by request
    $ua->agent('ClamTk/Automatic_Submission');
    $ua->timeout(60);

    # Submit these variables, plus $chosen (the file)
    my $sendername  = $name_entry->get_text;
    my $email       = $email_entry->get_text;
    my $description = $desc_entry->get_text || '';
    my $sampleis    = ( $new_btn->get_active ) ? 'virus' : 'falsepositive';

    # URL we're posting to
    $url .= ( $sampleis eq 'virus' ) ? 'sendmalware.cgi' : 'sendfp.cgi';

    $statusbar->set_text( gettext('Please wait...') );
    Gtk2->main_iteration while ( Gtk2->events_pending );

    my $req = $ua->post(
        $url,
        Content_Type => 'multipart/form-data;charset=utf-8',
        Content      => [
            action       => 'submit',
            sendername   => encode( 'utf8', $sendername ),
            email        => encode( 'utf8', $email ),
            'Send virus' => 'submit',
            name         => encode( 'utf8', $description ),
            sampleis     => encode( 'utf8', $sampleis ),
            file         => [ encode( 'utf8', $chosen ) ],
            ],
            );

    # Generic success statement
    if (   $req->is_success
        && $req->decoded_content =~ /has been successfully sent/ ) {
        increase_amount();
        finish('success');
        # This means a file was submitted to be recognized, but already is
    } elsif ( $req->decoded_content =~ /already recognized/ ) {
        my $as = '';
        if ( $req->decoded_content =~ /as (.*?) . Be/ ) {
            $as = $1;
        }
        increase_amount();
        finish( 'known', $as );
        # This means a file was submitted as a false positive, but is
        # not currently detected
    } elsif ( $req->decoded_content =~ /This file is not detected by/ ) {
        increase_amount();
        finish('falsefalse');
    } else {
        finish('failed');
    }
}

sub finish {
    my $status = shift;
    my $known  = shift;

    $bottombar->hide();

    my $message = "\n";
    if ( $status eq 'success' ) {
        $message = gettext('The submission was successful!');
    } elsif ( $status eq 'known' ) {
        $message = gettext('The file you submitted is already recognized');
        $message .= "\n";
        if ($known) {
            $message .= "($known)";
        } else {
            $message .= '.';
        }
    } elsif ( $status eq 'falsefalse' ) {
        $message = gettext('This file is not currently a false positive');
    } else {
        $message = gettext(
            'Unable to complete the submission. Please try again later.');
    }
    $statusbar->set_text($message);
    clear();
    $close_btn->show();
}

sub create_view {
    my $view = Gtk2::TextView->new;
    $view->set_wrap_mode('word');
    $view->set_editable(FALSE);
    $view->set_cursor_visible(FALSE);
    $view->set_indent(5);

    my $sw = Gtk2::ScrolledWindow->new;
    $sw->set_shadow_type('etched-in');
    $sw->set_policy( 'never', 'never' );
    $sw->set_border_width(5);

    my @text = (
        gettext('With this form, you can:'),
        gettext('Report new viruses which are not detected'),
        gettext('Report clean files which are incorrectly detected'),
        gettext('Please do not submit more than two files per day.'),
        );

    my $line = "\n";
    $line .= $text[0];
    $line .= "\n\n";
    $line .= "* ";
    $line .= $text[1];
    $line .= "\n";
    $line .= "* ";
    $line .= $text[2];
    $line .= "\n\n";
    $line .= $text[3];
    $line .= "\n\n";

    my $buffer = $view->get_buffer;
    my $iter   = $buffer->get_iter_at_offset(0);
    $buffer->create_tag( 'mono', family     => 'Monospace' );
    $buffer->create_tag( 'red',  foreground => 'red' );
    $buffer->insert_with_tags_by_name( $iter, $line, 'mono' );
    $buffer->insert_with_tags_by_name( $iter, '* ',  'red' );
    $buffer->insert_with_tags_by_name( $iter,
        gettext('Indicates a required field'), 'mono' );

    $sw->add($view);
    return $sw;
}

sub field_check {
    # This subroutine sanity-checks all the fields to ensure
    # they're filled out properly.  Some of the fields are mandatory,
    # such as Name, Email and, of course, there must be a file.
    # The Description field check only removes leading and ending
    # white spaces (for now).
    # I'll likely take some heat for the 'mandatory' fields, but
    # those are ClamAV's rules, not mine. :)  I'm sure they
    # have their reasons.

    # check name_entry
    my $tmp = $name_entry->get_text();
    $tmp =~ s/^\s+//;
    $tmp =~ s/\s+$//;
    if ( !length( $name_entry->get_text() ) || !length($tmp) ) {
        $name_desc->set_markup(
            qq(<span underline="error" underline_color="red">$name_string</span>)
            );
        field_loop();
        $name_desc->set_markup($name_string);
        $name_entry->grab_focus();
        return 0;
    }

    # check email_entry
    $tmp = $email_entry->get_text();
    $tmp =~ s/^\s+//;
    $tmp =~ s/\s+$//;
    if ( !length( $email_entry->get_text() ) || !length($tmp) ) {
        $email_desc->set_markup(
            qq(<span underline="error" underline_color="red">$email_string</span>)
            );
        field_loop();
        $email_desc->set_markup($email_string);
        $email_entry->grab_focus();
        return 0;
    }

    # check file field
    if ( !-e $chosen ) {
        $file_status->set_markup(
            qq(<span underline="error" underline_color="red">$file_string</span>)
            );
        field_loop();
        $file_status->set_markup($long_string);
        $file_btn->grab_focus();
        return 0;
    }

    # check desc field
    $tmp = $desc_entry->get_text();
    $tmp =~ s/^\s+//;
    $tmp =~ s/\s+$//;
    $desc_entry->set_text($tmp);

    return;
}

sub field_loop {
    # This is a sexy non-blocking subroutine.
    # It actually only allows *something* to happen for a few seconds.
    my $loop = Glib::MainLoop->new;
    Glib::Timeout->add(
        1000,
        sub {
            $loop->quit;
            FALSE;
        } );
    $loop->run;
    return;
}

sub test_date {
    my ( $year1, $month1, $day1 ) = get_todays_date();
    my ( $year2, $month2, $day2 ) = get_file_date();
    #warn "year1 = >$year1<, month1 =>$month1<, day1 = >$day1<\n";
    #warn "year2 = >$year2<, month2 =>$month2<, day2 = >$day2<\n";
    my $diff = Delta_Days( $year1, $month1, $day1, $year2, $month2, $day2 );

    # The date in the file needs to be changed to today.
    # This will blow away the old one and create a new one
    if ($diff) {
        create_file();
    }
    return;
}

sub create_file {
    open( my $f, '>:encoding(UTF-8)', $file_path )
        or do {
        warn "Could not open $file_path to create_file: $!\n";
        return;
        };
    my $today = join( ':', get_todays_date() );
    print $f "$today:0";
    close($f);
    return;
}

sub get_amount {
    open( my $f, '<:encoding(UTF-8)', $file_path )
        or do {
        warn "Could not open $file_path for reading to get_amount: $!\n";
        return 3;
        };
    my $amount;
    while (<$f>) {
        chomp;
        # example: 2010:10:02:0
        ( undef, undef, undef, $amount ) = split /:/;
    }
    close($f);
    return $amount;
}

sub get_file_date {
    my ( $year, $month, $day );
    open( my $f, '<:encoding(UTF-8)', $file_path )
        or do {
        # We don't want to just die because we can't read the date
        # from the file.  So we'll just assume it's today instead.
        warn "Could not open $file_path for reading to get_file_date: $!\n";
        ( $year, $month, $day, undef ) = split /:/;
        return ( $year, $month, $day );
        };
    while (<$f>) {
        chomp;
        ( $year, $month, $day, undef ) = split /:/;
    }
    close($f);
    return ( $year, $month, $day );
}

sub increase_amount {
    my $current = get_amount();
    $current++;
    my $today = join( ':', get_todays_date() );

    open( my $f, '>:encoding(UTF-8)', $file_path )
        or do {
        warn "Could not open $file_path for writing to increase_amount: $!\n";
        return;
        };
    print $f "$today:$current";
    close($f);
    return;
}

sub get_todays_date {
    my ( $day, $month, $year ) = split / /, strftime( '%d %m %Y', localtime );
    return ( $year, $month, $day );
}

sub valid_email {
    my $check = shift;
#<<< Perltidy needs to ignore this.
    # email $reg is by jfriedl, Mastering Regular Expressions.
    my $reg =
'(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n
\015()]|\\[^\x80-\xff])*\))*\))*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\
xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"
]|\\[^\x80-\xff])*")(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xf
f]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[
^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\
xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;
:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*"))
*(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\
n\015()]|\\[^\x80-\xff])*\))*\))*@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\
\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\04
0)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-
\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?
:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80
-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\(
(?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]
\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\
\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*|(?:[^(\040)<>@,;:".\\\[\]\000-\0
37\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xf
f\n\015"]|\\[^\x80-\xff])*")(?:[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\03
7]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\
\[^\x80-\xff])*\))*\)|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*")*<(?:[\04
0\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]
|\\[^\x80-\xff])*\))*\))*(?:@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x
80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@
,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]
)|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^\\
\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff
])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^
\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-
\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-
\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\01
5()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*,(?
:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\0
15()]|\\[^\x80-\xff])*\))*\))*@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^
\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<
>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xf
f])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^
\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\x
ff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:
[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\00
0-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x8
0-\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*)*:(?:[\040\t]|\((?:[^\\\x80-\xff\n\
015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*)
?(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000
-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*")(?:(?:[\040\t]
|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[
^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xf
f]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\
\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:
[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*"))*(?:[\040\t]|\((?:[^\\\x80-\xff\n\
015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*@
(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n
\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff
]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\
]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\
xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?
:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80
-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@
,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff
])*\]))*(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x8
0-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*>)(?:[\040\t]|\((?:[^\\\x80-\xff\n\
015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*';
#>>>

    $reg =~ s/\n//g;
    if ( $check =~ /$reg/o ) {
        return 1;
    } else {
        $email_desc->set_markup(
            qq(<span underline="error" underline_color="red">$email_string</span>)
            );
        field_loop();
        $email_desc->set_markup($email_string);
        $email_entry->grab_focus();
        return 0;
    }
}

1;