Skip to content

Commit 0a69758

Browse files
committed
FileReader::isPathPrefix(): Work around lexically_normal() no longer preserving UNC slashes on Boost 1.78+ on Windows
1 parent 5d88b74 commit 0a69758

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libsolidity/interface/FileReader.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ bool FileReader::isPathPrefix(boost::filesystem::path const& _prefix, boost::fil
325325
// NOTE: On Windows paths starting with a slash (rather than a drive letter) are considered relative by boost.
326326
solAssert(_prefix.is_absolute() || isUNCPath(_prefix) || _prefix.root_path() == "/", "");
327327
solAssert(_path.is_absolute() || isUNCPath(_path) || _path.root_path() == "/", "");
328-
solAssert(_prefix == _prefix.lexically_normal() && _path == _path.lexically_normal(), "");
328+
// NOTE: On Windows before Boost 1.78 lexically_normal() would not replace the `//` UNC prefix with `\\\\`.
329+
// Later versions do. Use generic_path() to normalize all slashes to `/` and ignore that difference.
330+
// This does not make the assert weaker because == ignores slash type anyway.
331+
solAssert(_prefix == _prefix.lexically_normal().generic_string() && _path == _path.lexically_normal().generic_string(), "");
329332
solAssert(!hasDotDotSegments(_prefix) && !hasDotDotSegments(_path), "");
330333

331334
boost::filesystem::path strippedPath = _path.lexically_relative(

0 commit comments

Comments
 (0)