From 062bad107fb98c58b8496930f328ae8a9f2397df Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 15 Oct 2015 01:00:16 +0100 Subject: Handle redirect URL being a complete URL, fixes behaviour in Apache 2.4.17 --- project2/cgi/cgiRequestContext.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/project2/cgi/cgiRequestContext.cpp b/project2/cgi/cgiRequestContext.cpp index 24de206..94d0973 100644 --- a/project2/cgi/cgiRequestContext.cpp +++ b/project2/cgi/cgiRequestContext.cpp @@ -60,7 +60,17 @@ CgiRequestContext::getRequestMethod() const std::string CgiRequestContext::getRedirectURL() const { - return cgi.getEnvironment().getRedirectURL(); + auto rdurl = cgi.getEnvironment().getRedirectURL(); + auto css = (int)rdurl.find("://"); + if (css > -1) { + auto s = rdurl.find('/', css + 3); + auto qm = (int)rdurl.find('?', s); + if (qm > -1) { + return rdurl.substr(s, qm - s); + } + return rdurl.substr(s); + } + return rdurl; } std::string -- cgit v1.2.3