Update of /cvsroot/mhonarc/mhonarc/MHonArc/lib
In directory subversions:/tmp/cvs-serv30607
Modified Files:
readmail.pl mhexternal.pl
Log Message:
[bug #4569]: Removed deletion of beginning whitespace character in
a continued line when unfolding.
Modified boundaryr paramter extraction for non-quoted
values to terminate at first semi-colon.
* Added entity numbers and parent entity header references in parsed
entity header hashes (client support request). How entities are
numbered may need to be modified after verification from client.
* Added newsserver option to external filter generate news URL links
for attachments (client support request). Leverages use of
entity part numbering.
Index: readmail.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/readmail.pl,v
retrieving revision 2.32
retrieving revision 2.33
diff -C2 -r2.32 -r2.33
*** readmail.pl 4 Feb 2003 23:31:20 -0000 2.32
--- readmail.pl 2 Aug 2003 06:04:47 -0000 2.33
***************
*** 341,344 ****
--- 341,345 ----
# Decode string
+ my $firsttime = 1;
while ($str =~ /(=\?([^?]+)\?(.)\?([^?]*)\?=)/g) {
# Grab components
***************
*** 357,370 ****
# Convert before (unencoded) text
! if (defined($encfunc)) { # encoding
! &$encfunc(\$str_before, $plain_real_charset, $TextEncode);
! $ret .= $str_before;
! } elsif ($dec_flag) { # ignore if just decode
! $ret .= $str_before;
! } elsif (defined(&$plaincnv)) { # decode and convert
! $ret .= &$plaincnv($str_before, $plain_real_charset);
! } else { # ignore
! $ret .= $str_before;
}
# Encoding text
--- 358,374 ----
# Convert before (unencoded) text
! if ($firsttime || $str_before =~ /\S/) {
! if (defined($encfunc)) { # encoding
! &$encfunc(\$str_before, $plain_real_charset, $TextEncode);
! $ret .= $str_before;
! } elsif ($dec_flag) { # ignore if just decode
! $ret .= $str_before;
! } elsif (defined(&$plaincnv)) { # decode and convert
! $ret .= &$plaincnv($str_before, $plain_real_charset);
! } else { # ignore
! $ret .= $str_before;
! }
}
+ $firsttime = 0;
# Encoding text
***************
*** 483,486 ****
--- 487,491 ----
$type = $subtype = '';
}
+ $fields->{'x-mha-content-type'} = $ctype;
## Check if type is excluded
***************
*** 568,572 ****
$boundary = $1;
} else {
! ($boundary) = $content =~ m/\bboundary\s*=\s*(\S+)/i;
$boundary =~ s/;$//; # chop ';' if grabbed
}
--- 573,577 ----
$boundary = $1;
} else {
! ($boundary) = $content =~ m/\bboundary\s*=\s*([^\s;]+)/i;
$boundary =~ s/;$//; # chop ';' if grabbed
}
***************
*** 642,645 ****
--- 647,651 ----
my %alt_exc = ( );
my $have_alt_prefs = $isalt && scalar(@_MIMEAltPrefs);
+ my $partno = 0;
@parts = \(@parts);
while (defined($part = shift(@parts))) {
***************
*** 648,651 ****
--- 654,658 ----
$href->{'body'} = $part;
$href->{'filtered'} = 0;
+ $partfields->{'x-mha-part-number'} = ++$partno;
$pctype = extract_ctype(
$partfields->{'content-type'}, $ctype);
***************
*** 693,696 ****
--- 700,705 ----
$partfields->{'content-base'} = [ $uribase ];
}
+
+ $partfields->{'x-mha-parent-header'} = $fields;
}
}
***************
*** 698,702 ****
my($entity);
ENTITY: foreach $entity (@entity) {
! next if $entity->{'filtered'};
## If content-type not defined for part, then determine
--- 707,713 ----
my($entity);
ENTITY: foreach $entity (@entity) {
! if ($entity->{'filtered'}) {
! next ENTITY;
! }
## If content-type not defined for part, then determine
***************
*** 750,757 ****
--- 761,779 ----
}
+ ## Aid garbage collection(?)
+ foreach $entity (@entity) {
+ delete $entity->{'fields'}{'x-mha-parent-header'};
+ }
+
## Else if message/rfc822 or message/news
} elsif ($ctype =~ m^\bmessage/(?:rfc822|news)\b^i) {
$partfields = (MAILread_header($body))[0];
+ # propogate parent and part no to message/* header
+ $partfields->{'x-mha-parent-header'} =
+ $fields->{'x-mha-parent-header'};
+ $partfields->{'x-mha-part-number'} =
+ $fields->{'x-mha-part-number'};
+
$ret = &$BeginEmbeddedMesgFunc();
if ($FormatHeaderFunc && defined(&$FormatHeaderFunc)) {
***************
*** 768,771 ****
--- 790,794 ----
push(@files, @array);
+ delete $partfields->{'x-mha-parent-header'};
## Else cannot handle type
***************
*** 824,828 ****
## Check for continuation of a field
! if ($tmp =~ s/^\s//) {
$fields->{$label}[-1] .= $tmp if $label;
next;
--- 847,851 ----
## Check for continuation of a field
! if ($tmp =~ /^\s/) {
$fields->{$label}[-1] .= $tmp if $label;
next;
***************
*** 876,880 ****
## Check for continuation of a field
! if ($tmp =~ s/^\s//) {
$fields->{$label}[-1] .= $tmp if $label;
next;
--- 899,903 ----
## Check for continuation of a field
! if ($tmp =~ /^\s/) {
$fields->{$label}[-1] .= $tmp if $label;
next;
***************
*** 1290,1293 ****
--- 1313,1333 ----
}
$charset;
+ }
+
+ ##---------------------------------------------------------------------------##
+ ## gen_full_part_number creates a full part number of an entity
+ ## from the given entity header.
+ ##
+ sub gen_full_part_number {
+ my $fields = shift;
+ my @number = ( );
+ while (defined($fields->{'x-mha-parent-header'})) {
+ unshift(@number, ($fields->{'x-mha-part-number'} || '1'));
+ $fields = $fields->{'x-mha-parent-header'};
+ }
+ if (!scalar(@number)) {
+ return $fields->{'x-mha-part-number'} || '1';
+ }
+ join('.', @number);
}
Index: mhexternal.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhexternal.pl,v
retrieving revision 2.15
retrieving revision 2.16
diff -C2 -r2.15 -r2.16
*** mhexternal.pl 31 Mar 2003 17:33:05 -0000 2.15
--- mhexternal.pl 2 Aug 2003 06:04:47 -0000 2.16
***************
*** 136,142 ****
}
## Get content-type
! ($ctype) = $fields->{'content-type'}[0] =~ m%^\s*([\w\-\./]+)%;
! $ctype =~ tr/A-Z/a-z/;
$type = (mhonarc::get_mime_ext($ctype))[1];
--- 136,146 ----
}
+ my($newsserver) = $args =~ /\bnewsserver=(\S+)/i;
+
## Get content-type
! if (!defined($ctype = $fields->{'x-mha-content-type'})) {
! ($ctype) = $fields->{'content-type'}[0] =~ m%^\s*([\w\-\./]+)%;
! $ctype =~ tr/A-Z/a-z/;
! }
$type = (mhonarc::get_mime_ext($ctype))[1];
***************
*** 158,162 ****
## Check if content is excluded based on filename extension
if ($excexts && index($excexts, ",$dispext,") >= $[) {
! return (qq|<p><tt><<attachment: |.
mhonarc::htmlize($nameparm).
qq|>></tt></p>\n|);
--- 162,166 ----
## Check if content is excluded based on filename extension
if ($excexts && index($excexts, ",$dispext,") >= $[) {
! return (qq|<p><tt><<attachment: |.
mhonarc::htmlize($nameparm).
qq|>></tt></p>\n|);
***************
*** 200,206 ****
## Write file
! $filename = mhonarc::write_attachment($ctype, $data, $path, $name, $inext);
! ($urlfile = $filename) =~ s/([^\w.\-\/])/sprintf("%%%X",unpack("C",$1))/ge;
! &debug("File-written: $filename") if $debug;
## Check if inlining when CT not image/*
--- 204,221 ----
## Write file
! if ($newsserver) {
! $urlfile = 'news://'.$newsserver.'/'.
! mhonarc::urlize($mhonarc::MHAmsgid).'?part='.
! readmail::gen_full_part_number($fields).'&type='.
! $fields->{'x-mha-content-type'};
! $urlfile .= '&filename='.$nameparm if $nameparm;
!
! } else {
! $filename =
! mhonarc::write_attachment($ctype, $data, $path, $name, $inext);
! ($urlfile = $filename) =~
! s/([^\w.\-\/])/sprintf("%%%X",unpack("C",$1))/ge;
! &debug("File-written: $filename") if $debug;
! }
## Check if inlining when CT not image/*
***************
*** 239,246 ****
#$namelabel = mhonarc::htmlize($nameparm);
$namelabel = $html_name;
! } else {
$namelabel = $filename;
$namelabel =~ s/^.*$mhonarc::DIRSEPREX//o;
mhonarc::htmlize(\$namelabel);
}
}
--- 254,263 ----
#$namelabel = mhonarc::htmlize($nameparm);
$namelabel = $html_name;
! } elsif ($filename) {
$namelabel = $filename;
$namelabel =~ s/^.*$mhonarc::DIRSEPREX//o;
mhonarc::htmlize(\$namelabel);
+ } else {
+ $namelabel = $ctype;
}
}
---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-DEV