Index: /trunk/gsdl/perllib/plugins/HTMLPlug.pm
===================================================================
--- /trunk/gsdl/perllib/plugins/HTMLPlug.pm	(revision 896)
+++ /trunk/gsdl/perllib/plugins/HTMLPlug.pm	(revision 897)
@@ -63,11 +63,12 @@
     print STDERR "   -block_exp             Files matching this regular expression will be blocked from\n";
     print STDERR "                          being passed to any further plugins in the list. By default\n";
-    print STDERR "                          HTMLPlug blocks any files with .gif, .jpg, .jpeg, .png, .pdf\n";
-    print STDERR "                          or .rtf file extensions.\n";
+    print STDERR "                          HTMLPlug blocks any files with .gif, .jpg, .jpeg, .png, .pdf,\n";
+    print STDERR "                          .rtf or .css file extensions.\n";
     print STDERR "   -keep_head             Don't remove headers from html files.\n";
     print STDERR "   -no_metadata           Don't attempt to extract any metadata from files.\n";
     print STDERR "   -metadata_fields       Comma separated list of metadata fields to attempt to extract.\n";
     print STDERR "                          Defaults to 'Title'\n";
-    print STDERR "   -w3mir                 Set if w3mir was used to generate input file structure.\n\n";
+    print STDERR "   -w3mir                 Set if w3mir was used to generate input file structure.\n";
+    print STDERR "                          w3mir \n";
 }
 
@@ -79,5 +80,5 @@
 			 q^process_exp/.*/(?i)\.html?$^, \$self->{'process_exp'},
 			 q^nolinks^, \$self->{'nolinks'},
-			 q^block_exp/.*/(?i)\.(gif|jpe?g|png|pdf|rtf)$^, \$self->{'block_exp'},
+			 q^block_exp/.*/(?i)\.(gif|jpe?g|png|pdf|rtf|css)$^, \$self->{'block_exp'},
 			 q^keep_head^, \$self->{'keep_head'},
 			 q^no_metadata^, \$self->{'no_metadata'},
@@ -159,11 +160,11 @@
 	    $self->replace_usemap_links($1, $2, $3)/isge;
 
-	$text =~ s/(<(?:a|area|frame)\s+[^>]*?(?:href|src)\s*=\s*\"?)([^\">\s]+)(\"?[^>]*>)/
-	    $self->replace_href_links ($1, $2, $3, $base_dir, $file, $doc_obj)/isge;
+	$text =~ s/(<(?:a|area|frame|link)\s+[^>]*?(?:href|src)\s*=\s*\"?)([^\">\s]+)(\"?[^>]*>)/
+	    $self->replace_href_links ($1, $2, $3, $base_dir, $file, $doc_obj, $cursection)/isge;
     }
 
     # trap images
     $text =~ s/(<img[^>]*?src\s*=\s*\"?)([^\">\s]+)(\"?[^>]*>)/
-	$self->replace_images ($1, $2, $3, $base_dir, $file, $doc_obj)/isge;
+	$self->replace_images ($1, $2, $3, $base_dir, $file, $doc_obj, $cursection)/isge;
 
     $doc_obj->add_text ($cursection, $text);
@@ -180,15 +181,16 @@
 sub replace_images {
     my $self = shift (@_);
-    my ($front, $link, $back, $base_dir, $file, $doc_obj) = @_;
+    my ($front, $link, $back, $base_dir, 
+	$file, $doc_obj, $section) = @_;
     
     $link =~ s/\n/ /g;
     
     my ($href, $hash_part, $rl) = $self->format_link ($link, $base_dir, $file);
-    return $front . $self->add_file ($href, $base_dir, $doc_obj) . $back;
+    return $front . $self->add_file ($href, $base_dir, $doc_obj, $section) . $back;
 }
 
 sub replace_href_links {
     my $self = shift (@_);
-    my ($front, $link, $back, $base_dir, $file, $doc_obj) = @_;
+    my ($front, $link, $back, $base_dir, $file, $doc_obj, $section) = @_;
 
     # attempt to sort out targets - frames are not handled 
@@ -207,14 +209,26 @@
 
     my ($filename) = $href =~ /^(?:.*?):(?:\/\/)?(.*)/;
+
+    ##### leave all these links alone (they won't be picked up by intermediate 
+    ##### pages). I think that's safest when dealing with frames, targets etc.
+    ##### (at least until I think of a better way to do it). Problems occur with
+    ##### mailto links from within small frames, the intermediate page is displayed
+    ##### within that frame and can't be seen. There is still potential for this to
+    ##### happen even with html pages - the solution seems to be to somehow tell
+    ##### the browser from the server side to display the page being sent (i.e. 
+    ##### the intermediate page) in the top level window - I'm not sure if that's 
+    ##### possible - the following line should probably be deleted if that can be done
+    return $front . $link . $back if $href =~ /^(mailto|news|gopher|nntp|telnet|javascript):/is;
+
+
     if (($rl == 0) || ($filename =~ /$self->{'process_exp'}/) || 
 	($href =~ /\/$/) || ($href =~ /^(mailto|news|gopher|nntp|telnet|javascript):/i)) {
-	$link = $href . $hash_part;
-	&html::urlsafe ($link);
-	return $front . "_httpextlink_&href=" . $link . "&rl=" . $rl . $back;
+	&html::urlsafe ($href);
+	return $front . "_httpextlink_&rl=" . $rl . "&href=" . $href . $hash_part . $back;
 	
     } else {
 	# link is to some other type of file (image, pdf etc.) so we'll
 	# need to associate that file
-	return $front . $self->add_file ($href, $base_dir, $doc_obj) . $back;
+	return $front . $self->add_file ($href, $base_dir, $doc_obj, $section) . $back;
     }
 }
@@ -222,5 +236,5 @@
 sub add_file {
     my $self = shift (@_);
-    my ($href, $base_dir, $doc_obj) = @_;
+    my ($href, $base_dir, $doc_obj, $section) = @_;
     my ($newname);
 
@@ -236,5 +250,5 @@
 	$self->inc_filecount ();
     }
-    $doc_obj->associate_file($filename, $newname);
+    $doc_obj->associate_file($filename, $newname, undef, $section);
     return "_httpcollimg_/$newname";
 }
