container: root: common: PluggablePath: add checks for invalid characters

This commit is contained in:
2025-12-23 10:54:57 -08:00
parent d2ff942fa0
commit 8bc6477c27

View File

@@ -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");