mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-03-12 10:21 am

[dw-free] Allow importing of your journal from another LiveJournal-based site.

[commit: http://hg.dwscoalition.org/dw-free/rev/e2645c125617]

http://bugs.dwscoalition.org/show_bug.cgi?id=114

Need to encode inputs into UTF-8.

Patch by [staff profile] mark.

Files modified:
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm
--------------------------------------------------------------------------------
diff -r 3a216b7a556c -r e2645c125617 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm	Thu Mar 12 09:51:50 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm	Thu Mar 12 10:21:16 2009 +0000
@@ -20,6 +20,7 @@ use base 'DW::Worker::ContentImporter::L
 use base 'DW::Worker::ContentImporter::LiveJournal';
 
 use Carp qw/ croak confess /;
+use Encode qw/ encode_utf8 /;
 use Time::HiRes qw/ tv_interval gettimeofday /;
 use DW::Worker::ContentImporter::Local::Comments;
 
@@ -258,6 +259,11 @@ sub try_work {
         $body =~ s/<.+?-embed-.+?>/[Embedded content removed during import.]/g;
         $body =~ s/<.+?-template-.+?>/[Templated content removed during import.]/g;
         $comment->{body} = $body;
+
+        # now let's do some encoding, just in case the input we get is in some other
+        # character encoding
+        $comment->{body} = encode_utf8( $comment->{body} );
+        $comment->{subject} = encode_utf8( $comment->{subject} );
     }
     
     # variable setup for the database work
--------------------------------------------------------------------------------