fix: ensure location blocks are not allowed in global context

This commit is contained in:
whaffman 2025-10-31 13:33:54 +01:00
parent 7072f71e00
commit cd64f98b31

View File

@ -1,5 +1,4 @@
#include <webserv/config/GlobalConfig.hpp>
#include <webserv/log/Log.hpp> // for Log
#include <webserv/utils/utils.hpp> // for findCorrespondingClosingBrace
@ -50,6 +49,11 @@ void GlobalConfig::parseBlock(const std::string &block)
servers_.emplace_back(std::make_unique<ServerConfig>(serverBlock, this));
pos = closeBrace + 1;
}
if (block.find("location", 0) != std::string::npos)
{
throw std::runtime_error("Location blocks are not allowed in the global context.");
}
parseDirectives(directives);
}