fixed bugs with < and > in headline
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 8 Jul 2003 08:24:13 +0000 (08:24 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 8 Jul 2003 08:24:13 +0000 (08:24 +0000)
git-svn-id: file:///home/dpavlin/private/svn/webpac/trunk@80 13eb9ef6-21d5-0310-b721-a9d68796d827

WebPac.pm
back2html.pm

index 6afdba8..cb361a0 100644 (file)
--- a/WebPac.pm
+++ b/WebPac.pm
@@ -117,6 +117,13 @@ sub show_results_list {
 
        my $tmpl = $self->load_tmpl('results.html');
 
+       sub esc_html {
+               my $html = shift;
+               $html =~ s/</&lt;/g;
+               $html =~ s/>/&gt;/g;
+               return $html;
+       }
+
        # call swish
        my $sh = SWISH->connect('Fork',
                prog     => $SWISH,
@@ -128,7 +135,7 @@ sub show_results_list {
                        push @swish_results, {
                                nr => ($#swish_results + 2),
                                path => $hit->swishdocpath,
-                               headline => $from_utf8->convert($hit->headline),
+                               headline => esc_html($from_utf8->convert($hit->headline)),
                                html => back2html($from_utf8->convert($hit->html)),
                                rank => $hit->swishrank };
 
index 1df1342..d61922f 100644 (file)
@@ -7,6 +7,8 @@
 sub back2html {
        my $html = shift;
 
+       $html =~ s/</&lt;/g;
+       $html =~ s/>/&gt;/g;
        my $out;
        foreach $line (split(/\s*###\s*/,$html)) {
                $out .= "<tr><td valign=\"top\">";