summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordz <dz@e03df62e-2008-0410-955e-edbf42e46eb7>2009-01-09 01:12:46 +0000
committerdz <dz@e03df62e-2008-0410-955e-edbf42e46eb7>2009-01-09 01:12:46 +0000
commit0268121676bcd787a980aca0a6ebea36a8564cdd (patch)
treec7967810fc4a34f8e2cd2bec6bd6715c0c92ef3e
parent399e941c2255b6ef31afe11878ecab389ae7aa73 (diff)
Correctly match alias formats (was backwards) and avoid going on to other aliases if none match. Fixes bug #668 reported by Ankit, thanks.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10953 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_alias.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 423ad8c5b..e3e2e9a5d 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -139,7 +139,7 @@ class ModuleAlias : public Module
virtual int OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
{
- std::multimap<std::string, Alias>::iterator i;
+ std::multimap<std::string, Alias>::iterator i, upperbound;
/* If theyre not registered yet, we dont want
* to know.
@@ -151,6 +151,8 @@ class ModuleAlias : public Module
i = Aliases.find(command);
if (i == Aliases.end())
return 0;
+ /* Avoid iterating on to different aliases if no patterns match. */
+ upperbound = Aliases.upper_bound(command);
irc::string c = command.c_str();
/* The parameters for the command in their original form, with the command stripped off */
@@ -164,7 +166,7 @@ class ModuleAlias : public Module
SearchAndReplace(safe, "$", "\r");
- while (i != Aliases.end())
+ while (i != upperbound)
{
if (i->second.UserCommand)
{
@@ -228,6 +230,9 @@ class ModuleAlias : public Module
if (i == Aliases.end())
return 0;
+
+ /* Avoid iterating on to other aliases if no patterns match */
+ std::multimap<std::string, Alias>::iterator upperbound = Aliases.upper_bound(fcommand);
/* The parameters for the command in their original form, with the command stripped off */
@@ -242,7 +247,7 @@ class ModuleAlias : public Module
ServerInstance->Logs->Log("FANTASY", DEBUG, "fantasy: compare is %s and safe is %s", compare.c_str(), safe.c_str());
- while (i != Aliases.end())
+ while (i != upperbound)
{
if (i->second.ChannelCommand)
{
@@ -266,12 +271,12 @@ class ModuleAlias : public Module
{
if (a->CaseSensitive)
{
- if (InspIRCd::Match(compare, a->format, rfc_case_sensitive_map))
+ if (!InspIRCd::Match(compare, a->format, rfc_case_sensitive_map))
return 0;
}
else
{
- if (InspIRCd::Match(compare, a->format))
+ if (!InspIRCd::Match(compare, a->format))
return 0;
}
}