From 74a34261ab88988e311f24e58f3744c483b4b518 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Thu, 23 Jun 2016 23:11:49 -0300 Subject: [PATCH] Adds function removeBracketsIfNeeded to utils --- src/utils.cc | 8 ++++++++ src/utils.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/utils.cc b/src/utils.cc index 3c3e89da..f409e66f 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -133,6 +133,14 @@ int urldecode_nonstrict_inplace(unsigned char *input, } +std::string removeBracketsIfNeeded(std::string a) { + if ((a.at(0) == '"') and (a.at(a.length()-1) == '"')) { + a.pop_back(); + a.erase(0, 1); + } + return a; +} + std::vector split(std::string str, char delimiter) { std::vector internal; diff --git a/src/utils.h b/src/utils.h index beac334f..60cc6023 100644 --- a/src/utils.h +++ b/src/utils.h @@ -60,6 +60,7 @@ namespace modsecurity { std::vector expandEnv(const std::string& var, int flags); std::string find_resource(const std::string& file, const std::string& param); + std::string removeBracketsIfNeeded(std::string a); } // namespace modsecurity