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] changelog2012-02-01 12:37 am

[dw-free] Fix issue with truncated picture keywords

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

Fix issue with truncated picture keywords

The summary here is that sometimes, when people use characters that are not
standard Latin (i.e., when the byte value is higher than 0x7f), sometimes we
get in a situation where the LJ::text_trim function cuts off the right edge
because it assumes UTF-8 input and the input isn't.

The solution is to encode it as UTF-8, which is what this patch does. This
patch also re-enables the comment updating since that's the only way to fix
the situation where someone has run into this bug. Simply re-importing will
fix any broken comments.

This was a pain to track down.

Patch by [staff profile] mark.

Files modified:
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm
--------------------------------------------------------------------------------
diff -r 139ce6219023 -r 8b78cdfc4bc2 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm	Tue Jan 31 09:52:41 2012 -0600
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm	Wed Feb 01 00:45:26 2012 +0000
@@ -320,6 +320,9 @@
             # character encoding
             $comment->[C_body] = encode_utf8( $comment->[C_body] || '' );
             $comment->[C_subject] = encode_utf8( $comment->[C_subject] || '' );
+            foreach my $prop ( keys %{$comment->[C_props]} ) {
+                $comment->[C_props]->{$prop} = encode_utf8( $comment->[C_props]->{$prop} );
+            }
 
             # this body is done
             $comment->[C_body_fixed] = 1;                
@@ -358,9 +361,7 @@
                 $comment->[C_local_parentid] = $jtalkid_map->{$comment->[C_remote_parentid]}+0;
                 $comment->[C_id] = $jtalkid;
 
-# Temporarily disabled, this slows down reimports a LOT and we aren't
-# really doing anything with them.
-#DW::Worker::ContentImporter::Local::Comments->update_comment( $u, hashify( $comment ), \$err );
+                DW::Worker::ContentImporter::Local::Comments->update_comment( $u, hashify( $comment ), \$err );
                 $log->( 'ERROR: %s', $err ) if $err;
 
                 $comment->[C_done] = 1;
--------------------------------------------------------------------------------
kareila: (runaways)

[personal profile] kareila 2012-02-01 07:14 am (UTC)(link)
We love you Mark!
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2012-02-01 07:15 am (UTC)(link)
Wow. So small a patch for all the hassle it caused. Heh.
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2012-02-02 03:04 pm (UTC)(link)
Only 'dammit'? You're a stronger man than I. :)