diff options
author | chriseth <c@ethdev.com> | 2016-07-18 22:58:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-18 22:58:38 +0800 |
commit | 417fde3eab0f862f7265e6881d4dc4404b37497e (patch) | |
tree | e5c10cc79c9a90bd8937409867620b629c9bd51a | |
parent | efad1e05ac97c9460846778af566a7ec7f37d207 (diff) | |
parent | e90ebcd63be68db46da3d481ed33b734a0d5b6ff (diff) | |
download | dexon-solidity-417fde3eab0f862f7265e6881d4dc4404b37497e.tar.gz dexon-solidity-417fde3eab0f862f7265e6881d4dc4404b37497e.tar.zst dexon-solidity-417fde3eab0f862f7265e6881d4dc4404b37497e.zip |
Merge pull request #711 from chriseth/canonical
Store non-canonical version.
-rw-r--r-- | solc/CommandLineInterface.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 17ab5ba4..09c7c8e8 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -531,17 +531,17 @@ bool CommandLineInterface::processInput() CompilerStack::ReadFileCallback fileReader = [this](string const& _path) { - auto boostPath = boost::filesystem::path(_path); - if (!boost::filesystem::exists(boostPath)) + auto path = boost::filesystem::path(_path); + if (!boost::filesystem::exists(path)) return CompilerStack::ReadFileResult{false, "File not found."}; - boostPath = boost::filesystem::canonical(boostPath); + auto canonicalPath = boost::filesystem::canonical(path); bool isAllowed = false; for (auto const& allowedDir: m_allowedDirectories) { // If dir is a prefix of boostPath, we are fine. if ( - std::distance(allowedDir.begin(), allowedDir.end()) <= std::distance(boostPath.begin(), boostPath.end()) && - std::equal(allowedDir.begin(), allowedDir.end(), boostPath.begin()) + std::distance(allowedDir.begin(), allowedDir.end()) <= std::distance(canonicalPath.begin(), canonicalPath.end()) && + std::equal(allowedDir.begin(), allowedDir.end(), canonicalPath.begin()) ) { isAllowed = true; @@ -550,12 +550,12 @@ bool CommandLineInterface::processInput() } if (!isAllowed) return CompilerStack::ReadFileResult{false, "File outside of allowed directories."}; - else if (!boost::filesystem::is_regular_file(boostPath)) + else if (!boost::filesystem::is_regular_file(canonicalPath)) return CompilerStack::ReadFileResult{false, "Not a valid file."}; else { - auto contents = dev::contentsString(boostPath.string()); - m_sourceCodes[boostPath.string()] = contents; + auto contents = dev::contentsString(canonicalPath.string()); + m_sourceCodes[path.string()] = contents; return CompilerStack::ReadFileResult{true, contents}; } }; |