From 160a2ba45243229602fbe1e65e2bf3453d0fcd9e Mon Sep 17 00:00:00 2001 From: "ian%hixie.ch" Date: Sun, 26 Oct 2003 11:30:09 +0000 Subject: [PATCH] Escape nicks in regular expressions so that they still work even if the bot is called something silly like '[bot]'. Bug 134599. --- webtools/mozbot/BotModules/Infobot.bm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webtools/mozbot/BotModules/Infobot.bm b/webtools/mozbot/BotModules/Infobot.bm index cc6ffe0b47de..4a3bd958266b 100644 --- a/webtools/mozbot/BotModules/Infobot.bm +++ b/webtools/mozbot/BotModules/Infobot.bm @@ -224,7 +224,7 @@ sub DoFactoidCheck { 'is', # am => is $event->{'from'}, # subject $direct); - } elsif ($shortMessage =~ /^(no\s*, (\s*$event->{'nick'}\s*,)? \s+)? (?:remember\s*:\s+)? (.+?) \s+ (is|are) \s+ (also\s+)? (.+?) $/six) { + } elsif ($shortMessage =~ /^(no\s*, (\s*\Q$event->{'nick'}\E\s*,)? \s+)? (?:remember\s*:\s+)? (.+?) \s+ (is|are) \s+ (also\s+)? (.+?) $/six) { # the "remember:" prefix can be used to delimit the start of the actual content, if necessary. $self->SetFactoid($event, defined($1), # replace existing answer? @@ -233,7 +233,7 @@ sub DoFactoidCheck { defined($5), # add to existing answer? $6, # object ($direct or defined($2))); - } elsif ($shortMessage =~ /^(no\s*, (\s*$event->{'nick'}\s*,)? \s+)? (?:remember\s*:\s+)? I \s+ am \s+ (also\s+)? (.+?) $/osix) { + } elsif ($shortMessage =~ /^(no\s*, (\s*\Q$event->{'nick'}\E\s*,)? \s+)? (?:remember\s*:\s+)? I \s+ am \s+ (also\s+)? (.+?) $/osix) { # the "remember:" prefix can be used to delimit the start of the actual content, if necessary. $self->SetFactoid($event, defined($1), # replace existing answer?