From ad0ffd2752b6bb5f31a68d78b5ccce53d3a039ec Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 10 Aug 2004 07:42:38 +0000 Subject: [PATCH] Let's make sure people can't run levenshtein (an O(n**3) algorithm) on large inputs. I gave it to lambdaman almost 10 minutes ago and it's still not finished. --- plugins/Fun.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/Fun.py b/plugins/Fun.py index 5b6829b7d..129fa7084 100644 --- a/plugins/Fun.py +++ b/plugins/Fun.py @@ -290,7 +290,11 @@ class Fun(callbacks.Privmsg): between and ) """ (s1, s2) = privmsgs.getArgs(args, required=2) - irc.reply(str(utils.distance(s1, s2))) + if len(s1) > 512 or len(s2) > 512: + irc.error('Levenshtein distance is a complicated algorithm, try ' + 'it with some smaller inputs.') + else: + irc.reply(str(utils.distance(s1, s2))) def soundex(self, irc, msg, args): """ []