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-07-06 03:55 am

[dw-free] Fix issue with importer with invalid school names.

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

Fix issue with importer with invalid school names.

Patch by [staff profile] mark.

Files modified:
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal.pm
--------------------------------------------------------------------------------
diff -r d4e35c18bc4f -r ee7f71ffe6de cgi-bin/DW/Worker/ContentImporter/LiveJournal.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal.pm	Mon Jul 06 00:21:06 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal.pm	Mon Jul 06 03:55:12 2009 +0000
@@ -393,7 +393,15 @@ sub get_foaf_from {
     return undef unless ( $r && $r->is_success );
 
     my $parser = new XML::Parser( Handlers => { Start => $foaf_handler, Char => $foaf_content, End => $foaf_closer } );
-    $parser->parse( $r->content );
+
+    # work around a bug in the schools system that can lead to malformed wide characters
+    # getting put into the feed, breaking XML::Parser.  we just strip out all of the school
+    # entries.  if we ever need that data, we'll have to figure out how to fix the problem
+    # in a more sane fashion...
+    my $content = $r->content;
+    $content =~ s!<ya:school.+</foaf:Person>!</foaf:Person>!s;
+
+    $parser->parse( $content );
 
     return ( \%items, \@interests, \@schools );
 }
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org