From cd64f98b31441406136447691a33f95c6205219b Mon Sep 17 00:00:00 2001 From: whaffman Date: Fri, 31 Oct 2025 13:33:54 +0100 Subject: [PATCH] fix: ensure location blocks are not allowed in global context --- webserv/config/GlobalConfig.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webserv/config/GlobalConfig.cpp b/webserv/config/GlobalConfig.cpp index acf34a3..05355f1 100644 --- a/webserv/config/GlobalConfig.cpp +++ b/webserv/config/GlobalConfig.cpp @@ -1,5 +1,4 @@ #include - #include // for Log #include // for findCorrespondingClosingBrace @@ -50,6 +49,11 @@ void GlobalConfig::parseBlock(const std::string &block) servers_.emplace_back(std::make_unique(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); }