mhonarc-commits
[Top] [All Lists]

CVS: mhonarc/MHonArc/lib mhmsgextbody.pl,1.3,1.4

2003-01-17 19:58:17
Update of /cvsroot/mhonarc/mhonarc/MHonArc/lib
In directory subversions:/tmp/cvs-serv29674

Modified Files:
	mhmsgextbody.pl 
Log Message:
* Added support for http/x-http access type.  This appears to
  be an experimental access type since the general URI type can be
  used instead.
* Properly sanitize parameter data.
* Some minor cosmetic changes in the HTML generated.


Index: mhmsgextbody.pl
===================================================================
RCS file: /cvsroot/mhonarc/mhonarc/MHonArc/lib/mhmsgextbody.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** mhmsgextbody.pl	5 Sep 2001 15:48:15 -0000	1.3
--- mhmsgextbody.pl	18 Jan 2003 02:58:12 -0000	1.4
***************
*** 53,71 ****
      my $b_lfile = $args =~ /\blocal-file\b/i;
  
!     my $ret = "";
      my $parms = readmail::MAILparse_parameter_str($ctype, 1);
      my $access_type = lc $parms->{'access-type'}{'value'};
         $access_type =~ s/\s//g;
!     my $cdesc = $fields->{'content-description'}[0] || "";
  
      $$data =~ s/\A\s+//;
      my $dfields = readmail::MAILread_header($data);
!     my $dctype  = $dfields->{'content-type'}[0] || "";
!     my $dcte 	= $dfields->{'content-transfer-encoding'}[0] || "";
!     my $dmd5 	= $dfields->{'content-md5'}[0] || "";
!     my $size 	= $parms->{'size'}{'value'} || "";
!     my $perms 	= $parms->{'permission'}{'value'} || "";
!     my $expires	= $parms->{'expiration'}{'value'} || "";
!     my $name	= $parms->{'name'}{'value'} || "";
  
      ATYPE: {
--- 53,69 ----
      my $b_lfile = $args =~ /\blocal-file\b/i;
  
!     my $ret = '';
      my $parms = readmail::MAILparse_parameter_str($ctype, 1);
      my $access_type = lc $parms->{'access-type'}{'value'};
         $access_type =~ s/\s//g;
!     my $cdesc = mhonarc::htmlize($fields->{'content-description'}[0]) || '';
  
      $$data =~ s/\A\s+//;
      my $dfields = readmail::MAILread_header($data);
!     my $dctype  = mhonarc::htmlize($dfields->{'content-type'}[0]) || '';
!     my $dmd5 	= mhonarc::htmlize($dfields->{'content-md5'}[0]) || '';
!     my $size 	= mhonarc::htmlize($parms->{'size'}{'value'}) || '';
!     my $expires	= mhonarc::htmlize($parms->{'expiration'}{'value'}) || '';
!     my $name	= $parms->{'name'}{'value'} || '';
  
      ATYPE: {
***************
*** 73,89 ****
  	if ( $access_type eq 'ftp' ||
  	     $access_type eq 'anon-ftp' ||
! 	     $access_type eq 'tftp' ) {
! 	    my $site 	 = $parms->{'site'}{'value'};
! 	    my $dir 	 = $parms->{'directory'}{'value'} || "";
! 	       $dir	 = '/'.$dir  unless $dir =~ m|^/| || $dir eq "";
! 	    my $mode 	 = $parms->{'mode'}{'value'} || "";
! 	    my $proto	 = $access_type eq 'tftp' ? 'tftp' : 'ftp';
! 	    my $url	 = "$proto://" .
! 			   mhonarc::urlize($site) .
  			   $dir . '/' .
! 			   mhonarc::urlize($name);
  	    $ret	 = '<dl><dt>';
! 	    $ret	.= qq|<a href="$url">$cdesc</a><br>\n|
! 			    if $cdesc;
  	    $ret	.= qq|<a href="$url">&lt;$url&gt;</a></dt><dd>\n|;
  	    $ret	.= qq|Content-type: <tt>$dctype</tt><br>\n|
--- 71,101 ----
  	if ( $access_type eq 'ftp' ||
  	     $access_type eq 'anon-ftp' ||
! 	     $access_type eq 'tftp' ||
! 	     $access_type eq 'http' ||
! 	     $access_type eq 'x-http' ) {
! 
! 	    my $site 	 = $parms->{'site'}{'value'} ||
! 			   $parms->{'host'}{'value'} || '';
! 
! 	    my $port 	 = $parms->{'port'}{'value'} || '';
! 	       $port	 = ':'.$port  if $port ne '';
! 
! 	    my $dir 	 = $parms->{'directory'}{'value'} ||
! 			   $parms->{'path'}{'value'} || '';
! 	       $dir	 = '/'.$dir  unless $dir =~ m|^/| || $dir eq '';
! 
! 	    my $mode 	 = $parms->{'mode'}{'value'} || '';
! 
! 	    my $proto	 = ($access_type eq 'x-http' || $access_type eq 'http')
! 			   ? 'http'
! 			   : ($access_type eq 'tftp')
! 			     ? 'tftp'
! 			     : 'ftp';
! 	    my $url	 = $proto . '://' .
! 			   mhonarc::urlize($site.$port) .
  			   $dir . '/' .
! 			   mhonarc::urlize_path($name);
  	    $ret	 = '<dl><dt>';
! 	    $ret	.= qq|<em>$cdesc</em><br>\n| if $cdesc;
  	    $ret	.= qq|<a href="$url">&lt;$url&gt;</a></dt><dd>\n|;
  	    $ret	.= qq|Content-type: <tt>$dctype</tt><br>\n|
***************
*** 106,113 ****
  	if ($access_type eq 'local-file') {
  	    last ATYPE  unless $b_lfile;
! 	    my $site 	 = $parms->{'site'}{'value'} || "";
! 	    my $url	 = mhonarc::urlize("file://$name");
  	    $ret	 = '<dl><dt>';
! 	    $ret	.= qq|<a href="$url">$cdesc</a><br>\n|  if $cdesc;
  	    $ret	.= qq|<a href="$url">&lt;$url&gt;</a></dt><dd>\n|;
  	    $ret	.= qq|Content-type: <tt>$dctype</tt><br>\n|
--- 118,125 ----
  	if ($access_type eq 'local-file') {
  	    last ATYPE  unless $b_lfile;
! 	    my $site 	 = $parms->{'site'}{'value'} || '';
! 	    my $url	 = 'file://' . mhonarc::urlize_path($name);
  	    $ret	 = '<dl><dt>';
! 	    $ret	.= qq|<em>$cdesc</em><br>\n|  if $cdesc;
  	    $ret	.= qq|<a href="$url">&lt;$url&gt;</a></dt><dd>\n|;
  	    $ret	.= qq|Content-type: <tt>$dctype</tt><br>\n|
***************
*** 133,139 ****
  	if ($access_type eq 'url') {
  	    my $url 	 = $parms->{'url'}{'value'};
! 	       $url =~ s/\s+//g;
  	    $ret	 = '<dl><dt>';
! 	    $ret	.= qq|<a href="$url">$cdesc</a><br>\n|  if $cdesc;
  	    $ret	.= qq|<a href="$url">&lt;$url&gt;</a></dt><dd>\n|;
  	    $ret	.= qq|Content-type: <tt>$dctype</tt><br>\n|
--- 145,152 ----
  	if ($access_type eq 'url') {
  	    my $url 	 = $parms->{'url'}{'value'};
! 	       $url =~ s/[\s<>]+//g;
! 	       $url =~ s/javascript/_javascript_/ig;
  	    $ret	 = '<dl><dt>';
! 	    $ret	.= qq|<em>$cdesc</em><br>\n|  if $cdesc;
  	    $ret	.= qq|<a href="$url">&lt;$url&gt;</a></dt><dd>\n|;
  	    $ret	.= qq|Content-type: <tt>$dctype</tt><br>\n|

---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-DEV