[Perlwebmail-devel] < and > problem

ZUKERAN, shin shin@opus.or.jp
Sat, 13 Jul 2002 05:00:25 +0900


Hello, Jason.

I found another problem.

Supposing mail contains both '<' and '>'  (like this mail:)$B!"(B
When reply or forward the mail, between '<' and '>' will be missing. 

Since I just begin to use webmail, I do not understand what $inbody expresses. 
So, I do not know whether this patch is right or not. 

----
ZUKERAN, shin

--- webmail-orig.pl     Sat Jul 13 04:38:11 2002
+++ webmail-new.pl      Sat Jul 13 04:54:24 2002
@@ -364,8 +364,11 @@
 
        foreach my $line ($global{pop}->Body ( $global{messnum} )) {
                if (! $attach) {
-                       $line =~ s/<[^>]*>//gs;
-                       $global{message_body} .= ">" . $line . "\n";
+                       $line =~ s/&/&amp;/g;
+                       $line =~ s/</&lt;/g;
+                       $line =~ s/>/&gt;/g;
+                       $line =~ s/"/&quot;/g;
+                       $global{message_body} .= "&lt; " . $line . "\n";
                        next;
                }
                if ($inbody){
@@ -375,7 +378,7 @@
                                next;
                        }
                        $line =~ s/<[^>]*>//gs;
-                       $global{message_body} .= ">" . $line . "\n";
+                       $global{message_body} .= "&gt; " . $line . "\n";
                }
        }
 
@@ -425,8 +428,11 @@
        }
        foreach my $line ($global{pop}->Body ( $global{messnum} )) {
                if (! $attach) {
-                       $line =~ s/<[^>]*>//gs;
-                       $global{message_body} .= ">" . $line . "\n";
+                       $line =~ s/&/&amp;/g;
+                       $line =~ s/</&lt;/g;
+                       $line =~ s/>/&gt;/g;
+                       $line =~ s/"/&quot;/g;
+                       $global{message_body} .= "&gt; " . $line . "\n";
                        next;
                }
                if ($inbody){
@@ -436,7 +442,7 @@
                                next;
                        }
                        $line =~ s/<[^>]*>//gs;
-                       $global{message_body} .= ">" . $line . "\n";
+                       $global{message_body} .= "&gt; " . $line . "\n";
                }
        }