XRootD
Loading...
Searching...
No Matches
XrdOucPrivateUtils.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2024-2025 by European Organization for Nuclear Research (CERN)
3// Author: Cedric Caffy <cedric.caffy@cern.ch>
4//------------------------------------------------------------------------------
5// XRootD is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// XRootD is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17//------------------------------------------------------------------------------
18
19
23#ifndef XROOTD_XRDOUCPRIVATEUTILS_HH
24#define XROOTD_XRDOUCPRIVATEUTILS_HH
25
27
28#include <regex>
29#include <string>
30#include <unordered_set>
31#include <string_view>
32#include <vector>
33
37static inline bool is_subdirectory(const std::string_view dir,
38 const std::string_view subdir)
39{
40 if (subdir.size() < dir.size() || dir.empty())
41 return false;
42
43 if (subdir.compare(0, dir.size(), dir, 0, dir.size()) != 0)
44 return false;
45
46 return dir.size() == subdir.size() || subdir[dir.size()] == '/' || dir.back() == '/';
47}
48
56std::string obfuscateAuth(const std::string & input);
57
65void stripCgi(std::string& url, const std::unordered_set<std::string> &cgiKeys);
66void stripCgi(XrdOucString& url, const std::unordered_set<std::string> &cgiKeys);
67
68#endif //XROOTD_XRDOUCPRIVATEUTILS_HH
void stripCgi(std::string &url, const std::unordered_set< std::string > &cgiKeys)
static bool is_subdirectory(const std::string_view dir, const std::string_view subdir)
std::string obfuscateAuth(const std::string &input)