fix torrent link detection
authorChristian Garbs <mitch@cgarbs.de>
Sun, 28 Dec 2008 11:47:42 +0000 (12:47 +0100)
committerRalf Ertzinger <sun@lain.camperquake.de>
Sun, 28 Dec 2008 21:22:24 +0000 (22:22 +0100)
prevent endless loop, also simplify it

xmlrtorrent.pl

index 53dd4e6..3514100 100644 (file)
@@ -125,7 +125,6 @@ sub check_for_link {
     my $message = ($parammessage == -1) ? '' : $signal->[$parammessage];
     my $nick = ($paramnick == -1)?defined($server)?$server->{'nick'}:'':$signal->[$paramnick];
     my $g;
-    my $m;
     my $p;
 
     my $witem;
@@ -134,27 +133,19 @@ sub check_for_link {
     } else {
         $witem = Irssi::window_item_find($target);
     }
-
+    
     # Look if we should ignore this line
     if ($message =~ m,(?:\s|^)/nosave(?:\s|$),) {
         return;
     }
-
+       
     push_output($witem);
 
     # Look if there is a torrent link in there
-    $message =~ m,(http://\S*\.(?:torrent|penis)),;
-    $m = $1;
-    while (defined($m)) {
-        write_debug('Torrent-URL: %s', $m);
-        $torrentlist{$torrentindex++} = {'CHANNEL' => $target, 'NICK' => $nick, 'URL' => $m};
-
-        # Remove the matched part from the message and try again (there may be
-        # more!)
-        $message =~ s/$m//;
-
-        $message =~ m|(http://.*\.torrent)|;
-        $m = $1;
+       
+    while ($message =~ m,(http://\S*\.(?:torrent|penis)),g) {
+        write_debug('Torrent-URL: %s', $1);
+        $torrentlist{$torrentindex++} = {'CHANNEL' => $target, 'NICK' => $nick, 'URL' => $1};
     }
 
     pop_output();