]> sipb.mit.edu Git - ikiwiki.git/commitdiff
call decode_utf8 inside eval
authorJoey Hess <joey@kodama.kitenet.net>
Mon, 17 Nov 2008 20:56:15 +0000 (15:56 -0500)
committerJoey Hess <joey@kodama.kitenet.net>
Mon, 17 Nov 2008 20:56:15 +0000 (15:56 -0500)
holger reported that decode_utf8 was crashing with perl 5.8.8. Earlier, I
thought that passing 0 to the function avoided this with old perls, but
that was apparently not enough, it still crashes. So, put it inside the
eval, so we can at least recover from it crashing.

IkiWiki/Plugin/aggregate.pm

index c9c2880c5737a77bea1b4d268cb468a68b7cbc44..f256b3ac1a9a58a10324ee6e1eb3523cecf4da7c 100644 (file)
@@ -496,15 +496,19 @@ sub aggregate (@) { #{{{
                        # that contains invalid UTF-8 sequences. Convert
                        # feed to ascii to try to work around.
                        $feed->{message}.=" ".sprintf(gettext("(invalid UTF-8 stripped from feed)"));
                        # that contains invalid UTF-8 sequences. Convert
                        # feed to ascii to try to work around.
                        $feed->{message}.=" ".sprintf(gettext("(invalid UTF-8 stripped from feed)"));
-                       $content=Encode::decode_utf8($content, 0);
-                       $f=eval{XML::Feed->parse(\$content)};
+                       $f=eval {
+                               $content=Encode::decode_utf8($content, 0);
+                               XML::Feed->parse(\$content)
+                       };
                }
                if ($@) {
                        # Another possibility is badly escaped entities.
                        $feed->{message}.=" ".sprintf(gettext("(feed entities escaped)"));
                        $content=~s/\&(?!amp)(\w+);/&amp;$1;/g;
                }
                if ($@) {
                        # Another possibility is badly escaped entities.
                        $feed->{message}.=" ".sprintf(gettext("(feed entities escaped)"));
                        $content=~s/\&(?!amp)(\w+);/&amp;$1;/g;
-                       $content=Encode::decode_utf8($content, 0);
-                       $f=eval{XML::Feed->parse(\$content)};
+                       $f=eval {
+                               $content=Encode::decode_utf8($content, 0);
+                               XML::Feed->parse(\$content)
+                       };
                }
                if ($@) {
                        $feed->{message}=gettext("feed crashed XML::Feed!")." ($@)";
                }
                if ($@) {
                        $feed->{message}=gettext("feed crashed XML::Feed!")." ($@)";