diff --git a/libsolutil/CommonIO.cpp b/libsolutil/CommonIO.cpp index c933c552e..9cba3c954 100644 --- a/libsolutil/CommonIO.cpp +++ b/libsolutil/CommonIO.cpp @@ -132,22 +132,11 @@ int solidity::util::readStandardInputChar() string solidity::util::absolutePath(string const& _path, string const& _reference) { - boost::filesystem::path p(_path); - // Anything that does not start with `.` is an absolute path. - if (p.begin() == p.end() || (*p.begin() != "." && *p.begin() != "..")) - return _path; - boost::filesystem::path result(_reference); - - // If filename is "/", then remove_filename() throws. - // See: https://github.com/boostorg/filesystem/issues/176 - if (result.filename() != boost::filesystem::path("/")) - result.remove_filename(); - for (boost::filesystem::path::iterator it = p.begin(); it != p.end(); ++it) - if (*it == "..") - result = result.parent_path(); - else if (*it != ".") - result /= *it; - return result.generic_string(); + // TODO: Handle throw of boost::filesystem::filesystem_error + return boost::filesystem::canonical( + boost::filesystem::path(_path), + boost::filesystem::path(_reference).remove_filename(); + ).generic_string(); } string solidity::util::sanitizePath(string const& _path) { diff --git a/test/libsolidity/syntaxTests/imports/boost_filesystem_bug.sol b/test/libsolidity/syntaxTests/imports/boost_filesystem_bug.sol index 622b03062..62a71ec9f 100644 --- a/test/libsolidity/syntaxTests/imports/boost_filesystem_bug.sol +++ b/test/libsolidity/syntaxTests/imports/boost_filesystem_bug.sol @@ -2,3 +2,5 @@ // This test used to throw due to a bug in boost::filesystem. // See https://github.com/boostorg/filesystem/issues/176 import "."; +// ---- +// ParserError 6275: (////:122-133): Source "/" not found: File not supplied initially.