]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Factoids/Update.pl
* Stop recursive is also loops
[infobot.git] / src / Factoids / Update.pl
index 400012e52387e126765c803dba173bf3966c8f82..475e0d9500b0b2acd04fef48d063f39811727936 100644 (file)
@@ -120,7 +120,23 @@ sub update {
     }
 
     if ($also) {                       # 'is also'.
-       if ($exists =~ /^<REPLY> see /i) {
+        my $redircount = 5;
+        my $origlhs = $lhs;
+        while ($exists =~ /^<REPLY> ?see (.*)/i) {
+            $redircount--;
+            unless ($redircount) {
+                &msg($who, "$origlhs has too many levels of redirection.");
+                return 1;
+            }
+
+            $lhs = $1;
+            $exists = &getFactoid($lhs);
+            unless( $exists ) {
+                &msg($who, "$1 is a dangling redirection.");
+                return 1;
+            }
+        }
+       if ($exists =~ /^<REPLY> ?see (.*)/i) {
            &TODO("Update.pl: append to linked factoid.");
        }