--- loncom/interface/lonmsg.pm 2009/02/05 00:45:29 1.222 +++ loncom/interface/lonmsg.pm 2010/08/20 18:45:20 1.222.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.222 2009/02/05 00:45:29 raeburn Exp $ +# $Id: lonmsg.pm,v 1.222.2.1 2010/08/20 18:45:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -203,6 +203,8 @@ use Apache::lonnet; use HTML::TokeParser(); use Apache::lonlocal; use Mail::Send; +use HTML::Entities; +use Encode; use LONCAPA qw(:DEFAULT :match); { @@ -484,7 +486,8 @@ sub sendnotification { my $protocol = $Apache::lonnet::protocol{$homeserver}; $protocol = 'http' if ($protocol ne 'https'); my $url = $protocol.'://'.&Apache::lonnet::hostname($homeserver). - '/adm/email?username='.$touname.'&domain='.$toudom; + '/adm/email?username='.$touname.'&domain='.$toudom. + '&display='.&escape($msgid); my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid, $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid); my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend); @@ -537,13 +540,16 @@ to access the full message.',$url); } if ($userenv{'notifywithhtml'} ne '') { my @htmlexcerpt = split(/,/,$userenv{'notifywithhtml'}); + my $htmlfree = &make_htmlfree($text); foreach my $addr (@recipients) { if ($blocked) { $body = $bodybegin."\n".$blocktext."\n".$bodyend; } else { - my $sendtext = $text; + my $sendtext; if (!grep/^\Q$addr\E/,@htmlexcerpt) { - $sendtext =~ s/\<\/*[^\>]+\>//gs; + $sendtext = &htmlfree; + } else { + $sendtext = $text; } $body = $bodybegin.$bodysubj.$sendtext.$bodyend; } @@ -553,13 +559,20 @@ to access the full message.',$url); if ($blocked) { $body = $bodybegin."\n".$blocktext."\n".$bodyend; } else { - $text =~ s/\<\/*[^\>]+\>//gs; - $body = $bodybegin.$bodysubj.$text.$bodyend; + my $htmlfree = &make_htmlfree($text); + $body = $bodybegin.$bodysubj.$htmlfree.$bodyend; } &sendemail($to,$subject,$body,$touname,$toudom,$user_lh); } } +sub make_htmlfree { + my ($text) = @_; + $text =~ s/\<\/*[^\>]+\>//gs; + $text = &HTML::Entities::decode($text); + $text = &Encode::encode('utf8',$text); + return $text; +} sub newmail { if ((time-$env{'user.mailcheck.time'})>300) {