From 0a69758468a103bf3804a626341602146966c985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 8 Sep 2023 17:28:12 +0200 Subject: [PATCH] FileReader::isPathPrefix(): Work around lexically_normal() no longer preserving UNC slashes on Boost 1.78+ on Windows --- libsolidity/interface/FileReader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libsolidity/interface/FileReader.cpp b/libsolidity/interface/FileReader.cpp index 7eda87081..4197780e6 100644 --- a/libsolidity/interface/FileReader.cpp +++ b/libsolidity/interface/FileReader.cpp @@ -325,7 +325,10 @@ bool FileReader::isPathPrefix(boost::filesystem::path const& _prefix, boost::fil // NOTE: On Windows paths starting with a slash (rather than a drive letter) are considered relative by boost. solAssert(_prefix.is_absolute() || isUNCPath(_prefix) || _prefix.root_path() == "/", ""); solAssert(_path.is_absolute() || isUNCPath(_path) || _path.root_path() == "/", ""); - solAssert(_prefix == _prefix.lexically_normal() && _path == _path.lexically_normal(), ""); + // NOTE: On Windows before Boost 1.78 lexically_normal() would not replace the `//` UNC prefix with `\\\\`. + // Later versions do. Use generic_path() to normalize all slashes to `/` and ignore that difference. + // This does not make the assert weaker because == ignores slash type anyway. + solAssert(_prefix == _prefix.lexically_normal().generic_string() && _path == _path.lexically_normal().generic_string(), ""); solAssert(!hasDotDotSegments(_prefix) && !hasDotDotSegments(_path), ""); boost::filesystem::path strippedPath = _path.lexically_relative(