diff options
| author | fukachan <fukachan> | 2002-07-02 11:54:06 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2002-07-02 11:54:06 +0000 |
| commit | 21a7f384cd849e965faed90fd06ef61fd1a12b8b (patch) | |
| tree | 3d682597c2642c0c901f776eae1433ef29ee4a81 /fml | |
| parent | 7fb4112b99e2b0c8d3b2e60cb887a7e3a25401ef (diff) | |
| download | fml8-21a7f384cd849e965faed90fd06ef61fd1a12b8b.tar.gz fml8-21a7f384cd849e965faed90fd06ef61fd1a12b8b.tar.bz2 fml8-21a7f384cd849e965faed90fd06ef61fd1a12b8b.zip | |
more defined() checks
FNF-ify
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/lib/FML/Header.pm | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/fml/lib/FML/Header.pm b/fml/lib/FML/Header.pm index 0fdf746a..b127c85f 100644 --- a/fml/lib/FML/Header.pm +++ b/fml/lib/FML/Header.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Header.pm,v 1.43 2002/06/01 02:21:56 fukachan Exp $ +# $FML: Header.pm,v 1.44 2002/06/01 14:53:38 fukachan Exp $ # package FML::Header; @@ -12,9 +12,10 @@ package FML::Header; use strict; use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD); use Carp; -use Mail::Header; use FML::Log qw(Log LogWarn LogError); +use Mail::Header; +@ISA = qw(Mail::Header); =head1 NAME @@ -52,9 +53,6 @@ forward the request up to superclass C<Mail::header::new()>. =cut -@ISA = qw(Mail::Header); - - # Descriptions: forward new() request to the base class # Arguments: OBJ($self) HASH_REF($args) # Side Effects: none @@ -95,8 +93,10 @@ sub get { my ($self, @x) = @_; my $x = $self->SUPER::get(@x) || ''; + $x =~ s/\n$//; - $x; + + return $x; } @@ -128,7 +128,7 @@ sub address_clean_up my ($self, $addr) = @_; use Mail::Address; - my @addrlist = Mail::Address->parse($addr); + my (@addrlist) = Mail::Address->parse($addr); # only the first element in the @addrlist array is effective. if (defined $addrlist[0]) { @@ -164,12 +164,17 @@ return the C<boundary> defind in the header's Content-Type field. sub data_type { my ($header) = @_; - my ($type) = split(/;/, $header->get('content-type')); - if (defined $type) { - $type =~ s/\s*//g; - return $type; + my $content_type = $header->get('content-type'); + + if (defined $content_type) { + my ($type) = split(/;/, $content_type); + if (defined $type) { + $type =~ s/\s*//g; + return $type; + } } - undef; + + return undef; } @@ -180,14 +185,15 @@ sub data_type sub mime_boundary { my ($header) = @_; - my $m = $header->get('content-type'); + my $content_type = $header->get('content-type'); - if ($m =~ /boundary=\"(.*)\"/) { - return $1; - } - else { - undef; + if (defined $content_type) { + if ($content_type =~ /boundary=\"(.*)\"/) { + return $1; + } } + + return undef; } @@ -420,8 +426,8 @@ sub rewrite_date $header->add('X-Date', $orgdate) if ($orgdate); $header->replace('Date', $newdate); - Log("(debug) rewrite Orginal Date to 'X-Date: $orgdate'"); - Log("(debug) rewrite New Date to 'Date: $newdate'"); + Log("(debug) rewrite the orginal date to 'X-Date: $orgdate'"); + Log("(debug) rewrite the new date to 'Date: $newdate'"); } @@ -443,8 +449,9 @@ The keys are space separeted. sub delete_unsafe_header_fields { my ($header, $config, $args) = @_; - my (@fields) = split(/\s+/, $config->{ unsafe_header_fields }); - for (@fields) { $header->delete($_);} + my ($fields) = $config->get_as_array_ref('unsafe_header_fields'); + + for (@$fields) { $header->delete($_);} } @@ -470,10 +477,12 @@ References: fields. sub delete_subject_tag_like_string { my ($header, $str) = @_; + $str =~ s/\W[-\w]+.\s*\d+\W//g; $str =~ s/\s+/ /g; $str =~ s/^\s*//g; - $str; + + return $str; } @@ -501,7 +510,7 @@ sub extract_message_id_references } } - \@r; + return \@r; } |
