From c65590448cb15be3902b64c379fc0cb189c3d60c Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 22 Dec 2006 17:35:33 +0000 Subject: Fix for alias var names within aliases git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6059 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_alias.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/modules/m_alias.cpp') diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 55241c278..4e32f2856 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -144,7 +144,13 @@ class ModuleAlias : public Module std::string compare = original_line.substr(command.length()); while (*(compare.c_str()) == ' ') compare.erase(compare.begin()); - + + std::string safe(original_line); + + /* Escape out any $ symbols in the user provided text */ + + SearchAndReplace(safe, "$", "\r"); + for (unsigned int i = 0; i < Aliases.size(); i++) { if (Aliases[i].text == c) @@ -184,7 +190,7 @@ class ModuleAlias : public Module if (crlf == std::string::npos) { ServerInstance->Log(DEBUG,"Single line alias: '%s'", Aliases[i].replace_with.c_str()); - DoCommand(Aliases[i].replace_with, user, original_line); + DoCommand(Aliases[i].replace_with, user, safe); return 1; } else @@ -195,7 +201,7 @@ class ModuleAlias : public Module while ((command = commands.GetToken()) != "") { ServerInstance->Log(DEBUG,"Execute: '%s'", command.c_str()); - DoCommand(command, user, original_line); + DoCommand(command, user, safe); } return 1; } @@ -238,6 +244,9 @@ class ModuleAlias : public Module SearchAndReplace(newline, "$host", user->host); SearchAndReplace(newline, "$vhost", user->dhost); + /* Unescape any variable names in the user text before sending */ + SearchAndReplace(newline, "\r", "$"); + irc::tokenstream ss(newline); const char* parv[127]; int x = 0; -- cgit v1.2.3