TestCaseReader: Disallow UNC paths along with absolute ones

This commit is contained in:
Kamil Śliwak 2021-06-25 14:23:01 +02:00
parent 34425c351d
commit e841479b4b

View File

@ -159,7 +159,9 @@ pair<SourceMap, size_t> TestCaseReader::parseSourcesAndSettingsWithLineNumber(is
soltestAssert(!externalSourceName.empty(), ""); soltestAssert(!externalSourceName.empty(), "");
fs::path externalSourceTarget(externalSourceString); fs::path externalSourceTarget(externalSourceString);
fs::path testCaseParentDir = m_fileName.parent_path(); fs::path testCaseParentDir = m_fileName.parent_path();
if (!externalSourceTarget.is_relative()) if (!externalSourceTarget.is_relative() || !externalSourceTarget.root_path().empty())
// NOTE: UNC paths (ones starting with // or \\) are considered relative by Boost
// since they have an empty root directory (but non-empty root name).
BOOST_THROW_EXCEPTION(runtime_error("External Source paths need to be relative to the location of the test case.")); BOOST_THROW_EXCEPTION(runtime_error("External Source paths need to be relative to the location of the test case."));
fs::path externalSourceFullPath = testCaseParentDir / externalSourceTarget; fs::path externalSourceFullPath = testCaseParentDir / externalSourceTarget;
string externalSourceContent; string externalSourceContent;