diff --git a/src/actions/redirect.cc b/src/actions/redirect.cc index 4f1a7675..1f4af306 100644 --- a/src/actions/redirect.cc +++ b/src/actions/redirect.cc @@ -19,6 +19,7 @@ #include #include "modsecurity/assay.h" +#include "src/macro_expansion.h" namespace ModSecurity { namespace actions { @@ -28,13 +29,14 @@ Redirect::~Redirect() { Redirect::Redirect(const std::string& action) : Action(action, RunTimeOnlyIfMatchKind), - url(action) { - this->url = this->url.erase(0, 9); - this->status = 302; + m_url(action) { + m_url = m_url.erase(0, 9); + m_status = 302; } bool Redirect::evaluate(Rule *rule, Assay *assay) { + m_urlExpanded = MacroExpansion::expand(m_url, assay); assay->actions.push_back(this); return true; } @@ -42,10 +44,10 @@ bool Redirect::evaluate(Rule *rule, Assay *assay) { void Redirect::fill_intervention(ModSecurityIntervention *i) { /* if it was changed before, lets keep it. */ if (i->status == 200) { - i->status = this->status; + i->status = m_status; } - // reinterpret_cast - i->url = this->url.c_str(); //** TODO: wheee */ + + i->url = m_urlExpanded.c_str(); i->log = "Redirecting"; } diff --git a/src/actions/redirect.h b/src/actions/redirect.h index 3da9d736..24bb55b5 100644 --- a/src/actions/redirect.h +++ b/src/actions/redirect.h @@ -34,10 +34,12 @@ class Redirect : public Action { ~Redirect() override; bool evaluate(Rule *rule, Assay *assay) override; - int status; - std::string url; void fill_intervention(ModSecurityIntervention *i) override; bool isDisruptive() override { return true; } + private: + int m_status; + std::string m_urlExpanded; + std::string m_url; }; } // namespace actions