forked from EvergreenCrypto/docker-finance
container: root: common: PluggablePath: add checks for invalid characters
This commit is contained in:
@@ -300,6 +300,20 @@ class PluggablePath
|
||||
//! \return NPI reference
|
||||
auto& parse()
|
||||
{
|
||||
// Invalid characters
|
||||
const std::regex regex{"[a-zA-Z0-9/_\\-\\.]+"};
|
||||
const std::string msg{"invalid characters in path"};
|
||||
|
||||
if (!m_path.repo().empty())
|
||||
throw_ex_if<type::RuntimeError>(
|
||||
!std::regex_match(m_path.repo(), regex), msg);
|
||||
|
||||
if (!m_path.custom().empty())
|
||||
throw_ex_if<type::RuntimeError>(
|
||||
!std::regex_match(m_path.custom(), regex), msg);
|
||||
|
||||
throw_ex_if<type::RuntimeError>(!std::regex_match(m_pseudo, regex), msg);
|
||||
|
||||
// Parse out pseudo tag
|
||||
auto pos = m_pseudo.find('/');
|
||||
throw_ex_if<type::RuntimeError>(!pos, "no pseudo tag");
|
||||
|
||||
Reference in New Issue
Block a user