--- trunk/MWS.pm 2004/05/07 23:35:39 20 +++ trunk/MWS.pm 2004/05/08 00:54:16 21 @@ -14,6 +14,7 @@ use Text::Unaccent; use Date::Parse; use POSIX qw(strftime); +use MIME::Base64; #use MWS_plucene; use MWS_swish; @@ -205,12 +206,12 @@ sub search { my $self = shift; - my $s = shift || carp "search called without argument!"; + carp "search called without argument!" if (! @_); $self->reset_counters; - print STDERR "search_index($s)\n" if ($debug == 2); - my @index_ids = $self->search_index($s); + print STDERR "search(",join(" ",@_),")\n" if ($debug == 2); + my @index_ids = $self->search_index(@_); $self->{'index_ids'} = \@index_ids; @@ -231,17 +232,28 @@ my $tmp = shift || return; - sub decode($$) { - my ($cp,$qp) = @_; - print STDERR "decode($cp,$qp) -> " if ($debug == 2); - $qp =~ s/=([a-f0-9][a-f0-9])/chr(hex($1))/ieg; - $qp =~ s/_/ /g; - print STDERR "$qp -> " if ($debug == 2); + sub decode($$$) { + my ($cp,$enc,$qp) = @_; + + print STDERR "decode($cp,$qp) -> " if ($debug == 2); + + if (uc($enc) eq "Q") { + $qp =~ s/=([a-f0-9][a-f0-9])/chr(hex($1))/ieg; + $qp =~ s/_/ /g; + } elsif (uc($enc) eq "B") { + $qp = decode_base64($qp); + } else { + croak "unsupported encoding '$enc' in decode_qp\n"; + return $qp; + } + + print STDERR "$qp -> " if ($debug == 2); + my $iconv = Text::Iconv->new($cp,'ISO-8859-2'); return $iconv->convert($qp) || ''; } - $tmp =~ s/=\?([^\?]+)\?Q\?(.+?)\?=/decode($1,$2)/ge; + $tmp =~ s/=\?([^\?]+)\?([QB])\?(.+?)\?=/decode($1,$2,$3)/ige; $tmp =~ s/^\s*["']+(.*?)["']+\s*$/$1/g; #print STDERR "$tmp\n" if ($debug == 2); return $tmp; @@ -320,7 +332,7 @@ my $wrap = $self->{wrap_margin}; if ($wrap && $body && $body =~ m/^.{$wrap}..*$/m) { $body =~ s/[\r\n]/\n/gs; - $body = autoformat($body, {right=>$wrap}); + $body = autoformat($body, {right=>$wrap, all=>1}); $body .="\n[reformated using autoformat, margin at $wrap]" if ($debug == 2); }