/[mws]/trunk/httpd.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/httpd.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by dpavlin, Sun May 9 00:09:32 2004 UTC revision 39 by dpavlin, Mon May 10 14:07:44 2004 UTC
# Line 28  be used. Line 28  be used.
28          exit 1;          exit 1;
29  }  }
30    
 my $d = HTTP::Daemon->new( Reuse => 1, LocalPort => 6969 ) || die;  
 my $cgi = new CGI::Lite;  
31  my $mws = MWS->new($config_file);  my $mws = MWS->new($config_file);
32    
33    my ($local_addr,$local_port) = ('127.0.0.1',6969);
34    
35    my $listen = $mws->{config}->val('global', 'listen');
36    if ($listen =~ m/:/) {
37            ($local_addr,$local_port) = split(/:/,$listen);
38    } elsif ($listen) {
39            $local_addr = $listen;
40    }
41    
42    my $d = HTTP::Daemon->new(
43            Reuse => 1,
44            LocalAddr => $local_addr,
45            LocalPort => $local_port,
46    ) || die "can't create HTTP::Daemon";
47    
48    my $cgi = new CGI::Lite;
49  my $tt = Template->new({  my $tt = Template->new({
50          INCLUDE_PATH => $mws->{config}->val('global', 'templates'),          INCLUDE_PATH => $mws->{config}->val('global', 'templates'),
51          FILTERS => {          FILTERS => {
# Line 217  sub html_escape($) { Line 232  sub html_escape($) {
232          my $text = shift || return;          my $text = shift || return;
233    
234          # don't re-escape html          # don't re-escape html
235          #return $text if ($text =~ /&(:?lt|gt|amp|quot);/);          #return $text if ($text =~ /&(?:lt|gt|amp|quot);/);
236    
237          # Escape <, >, & and ", and to produce valid XML          # Escape <, >, & and ", and to produce valid XML
238          my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');          my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');
239          my $escape_re  = join '|' => keys %escape;          my $escape_re  = join '|' => keys %escape;
240    
241          $text =~ s/($escape_re)/$escape{$1}/gs;          $text =~ s/($escape_re)/$escape{$1}/gs;
242    
243            while ($text =~ s/#-#(quote|signature)(\d*)##(.+?)##\1\2#-#/<span class="$1">$3<\/span>/gs) { } ;
244    
245          return $text;          return $text;
246  }  }
247    
# Line 233  sub body5_filter { Line 251  sub body5_filter {
251          my $text = shift;          my $text = shift;
252    
253          # remove quote          # remove quote
254          $text =~ s/^[\>:\|=]+\s*.*?$/#-q-#/msg;          $text =~ s/^[\>:\|=]+[^\n\r]*[\n\r]*$/#-q-#/msg;
255          # remove quote author          # remove quote author
256          $text =~ s/[\n\r]+[^\n\r]+:\s*(:?#-q-#[\n\r*])+//gs;          $text =~ s/[\n\r]+[^\n\r]+:\s*(?:#-q-#[\n\r*])+//gs;
257          $text =~ s/^[^\n\r]+:\s*(:?#-q-#[\n\r]*)+//gs;          $text =~ s/^[^\n\r]+:\s*(?:#-q-#[\n\r]*)+//gs;
258          $text =~ s/#-q-#[\n\r]*//gs;          $text =~ s/#-q-#[\n\r]*//gs;
259          # outlook quoting          # outlook quoting
260          $text =~ s/(\s*--+\s*Original\s+Message\s*--+.*)$//si;          $text =~ s/(\s*--+\s*Original\s+Message\s*--+.*)$//si;
261          $text =~ s/(\s*--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$//si;          $text =~ s/(\s*--+\s*Forwarded\s+message.+\s*--+.*)$//si;
262    
263          # remove signature          # remove signature
264          $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s;          $text =~ s/[\n\r]+--\s*[\n\r]+.*$//s;
# Line 252  sub body5_filter { Line 270  sub body5_filter {
270          $text =~ s/^\n+//gs;          $text =~ s/^\n+//gs;
271          $text =~ s/[\s\n]+$//gs;          $text =~ s/[\s\n]+$//gs;
272    
273            if ($text eq "") {
274                    $text="#-#quote##forwarded message##quote#-#";
275            }
276    
277          # cut to 5 lines;          # cut to 5 lines;
278          if ($text =~ s,^((?:.*?[\n\r]){5}).*$,$1,s) {          if ($text =~ s,^((?:.*?[\n\r]){5}).*$,$1,s) {
279                  $text =~ s/[\n\r]*$/ .../;                  $text =~ s/[\n\r]*$/ .../;
# Line 274  sub body_filter { Line 296  sub body_filter {
296          }          }
297    
298          # find quoted text          # find quoted text
299          $text =~ s/^([\>:\|=]+\s*.*?)$/#-#quote1##$1##quote1#-#/msg;          $text =~ s/^([\>:\|=]+[^\n\r]*[\n\r]*)$/#-#quote1##$1##quote1#-#/mg;
300          $text =~ s/(--+\s*Original\s+Message\s*--+.*)$/#-#quote2##$1##quote2#-#/si;          $text =~ s/(--+\s*Original\s+Message\s*--+.*)$/#-#quote2##$1##quote2#-#/si;
301          $text =~ s/(--+\s*Forwarded\s+message\s*from\s+.+\s*--+.*)$/#-#quote3##$1##quote3#-#/si;          $text =~ s/(--+\s*Forwarded\s+message.+\s*--+.*)$/#-#quote3##$1##quote3#-#/si;
302    
303          $text = html_escape($text . $sig);          $text = html_escape($text . $sig);
         while ($text =~ s/#-#(quote|signature)(\d*)##(.+?)##\1\2#-#/<span class="$1">$3<\/span>/gs) { } ;  
304          return $text;          return $text;
305  }  }
306    

Legend:
Removed from v.30  
changed lines
  Added in v.39

  ViewVC Help
Powered by ViewVC 1.1.26