here is an updated version of Kiwamu OkabeĀ“s patch with a regex that is
less brittle. It still does not deal with the localhost/doc use case but
fixes the obvious breakage.

-- 
--
Ben Hildred
Automation Support Services
303 815 6721
--- dwww-convert.orig	2012-09-11 22:59:37.419260722 +0900
+++ dwww-convert	2012-09-11 22:58:19.138872558 +0900
@@ -284,6 +284,25 @@
 } # }}}
 
 #
+# Filter html file. Change href link.
+# /usr/share/doc/ => /cgi-bin/dwww/usr/share/doc/
+#
+sub BuiltinHtmlFilter() { # {{{
+    my $filename    = shift;
+    my $cacheProg   = shift;
+    my $charset     = shift;
+
+    my $OUT_FH      = &OpenPipe($cacheProg, "w");
+    my $IN_FH       = &OpenPipe("cat \"$filename\"", "r");
+    while (<$IN_FH>) {
+	$_ =~ s!(href=['"]?)(/usr/share/doc/!$1/cgi-bin/dwww$2!g;
+        print $OUT_FH $_;
+    }
+    &ClosePipe($IN_FH);
+    &ClosePipe($OUT_FH);
+} # }}}
+
+#
 # Convert info file to HTML using info2www
 #
 sub BuiltinInfo2Html() { # {{{
@@ -494,6 +513,8 @@
     $convertFunction  =   \&BuiltinInfo2Html;
 } elsif ($type eq "text/plain") {
     $convertFunction  =   \&BuiltinText2Html;
+} elsif ($type eq "text/html") {
+    $convertFunction  =   \&BuiltinHtmlFilter;
 } elsif ($type ne  "html") {
     $mime_type  =   $type;
 }

Reply via email to