ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[livejournal] r16173: LJSV-861: UTF bug in plain text notifica...

Committer: ssafronova
LJSV-861: UTF bug in plain text notification
U   trunk/cgi-bin/LJ/Comment.pm
U   trunk/cgi-bin/ljmail.pl
Modified: trunk/cgi-bin/LJ/Comment.pm
===================================================================
--- trunk/cgi-bin/LJ/Comment.pm	2010-01-29 09:20:40 UTC (rev 16172)
+++ trunk/cgi-bin/LJ/Comment.pm	2010-01-29 09:31:24 UTC (rev 16173)
@@ -17,6 +17,8 @@
 require "htmlcontrols.pl";
 require "talklib.pl";
 
+use Encode();
+
 # internal fields:
 #
 #    journalid:     journalid where the commend was
@@ -1043,9 +1045,15 @@
 }
 
 sub indent {
-    return LJ::Talk::Post::indent(@_);
+    my $str = shift;
+    return Encode::encode_utf8( LJ::Talk::Post::indent( Encode::decode_utf8($str), @_) );
 }
 
+sub wrap {
+    my $str = pop;
+    return Encode::encode_utf8( Text::Wrap::wrap( @_, Encode::decode_utf8($str) ) );
+}
+
 sub blockquote {
     return LJ::Talk::Post::blockquote(@_);
 }
@@ -1365,12 +1373,12 @@
         $body .= "<br />";
     } else {
         if (my $subj = $self->subject_raw) {
-            $body .= Text::Wrap::wrap(" " . LJ::Lang::get_text($lang, $ml_prefix . 'subject', undef) . " ", "", $subj) . "\n\n";
+            $body .= wrap(" " . LJ::Lang::get_text($lang, $ml_prefix . 'subject', undef) . " ", "", $subj) . "\n\n";
         }
         $body .= indent($self->body_raw) . "\n\n";
 
         # Don't wrap options, only text.
-        $body = Text::Wrap::wrap("", "", $body) . "\n";
+        $body = wrap("", "", $body) . "\n";
     }
 
     my $can_unscreen = $self->is_screened &&

Modified: trunk/cgi-bin/ljmail.pl
===================================================================
--- trunk/cgi-bin/ljmail.pl	2010-01-29 09:20:40 UTC (rev 16172)
+++ trunk/cgi-bin/ljmail.pl	2010-01-29 09:31:24 UTC (rev 16173)
@@ -87,7 +87,7 @@
             return $name ? "\"$name\" <$email>" : $email;
         };
 
-        my $body = $opt->{'wrap'} ? Text::Wrap::wrap('','',$opt->{'body'}) : $opt->{'body'};
+        my $body = $opt->{'wrap'} ? Encode::encode_utf8(Text::Wrap::wrap('','',Encode::decode_utf8($opt->{'body'}))) : $opt->{'body'};
         my $subject = $opt->{'subject'};
         my $fromname = $opt->{'fromname'};
 

Tags: livejournal, pl, pm, ssafronova
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments