mirror of
https://github.com/anope/anope.git
synced 2026-06-29 00:26:39 +02:00
Allow escaping brackets in webpanel templates and redirect users to the homepage when their session is not found
This commit is contained in:
@@ -115,9 +115,12 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n
|
||||
|
||||
Anope::string finished;
|
||||
|
||||
bool escaped = false;
|
||||
for (unsigned j = 0; j < buf.length(); ++j)
|
||||
{
|
||||
if (buf[j] == '{')
|
||||
if (buf[j] == '\\' && j + 1 < buf.length() && (buf[j + 1] == '{' || buf[j + 1] == '}'))
|
||||
escaped = true;
|
||||
else if (buf[j] == '{' && !escaped)
|
||||
{
|
||||
size_t f = buf.substr(j).find('}');
|
||||
if (f == Anope::string::npos)
|
||||
@@ -241,6 +244,8 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n
|
||||
}
|
||||
else
|
||||
{
|
||||
escaped = false;
|
||||
|
||||
// If the if stack is empty or we are in a true statement
|
||||
bool ifok = IfStack.empty() || IfStack.top();
|
||||
bool forok = ForLoop::Stack.empty() || !ForLoop::Stack.back().finished(r);
|
||||
|
||||
@@ -88,6 +88,8 @@ class WebPanelProtectedPage : public WebPanelPage
|
||||
|
||||
if (!panel || !(na = panel->GetNickFromSession(client, message)))
|
||||
{
|
||||
reply.error = HTTP_FOUND;
|
||||
reply.headers["Location"] = Anope::string("http") + (use_ssl ? "s" : "") + "://" + message.headers["Host"] + "/";
|
||||
return true; // Access denied
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user