From 9128e73b03856c72e90c581cb36e931e971af29e Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 2 Jan 2017 16:13:57 +0100 Subject: docs: clarify what are considered as absolute paths --- docs/layout-of-source-files.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index dff48be3..1e27b7c0 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -79,8 +79,9 @@ Paths ----- In the above, ``filename`` is always treated as a path with ``/`` as directory separator, -``.`` as the current and ``..`` as the parent directory. Path names that do not start -with ``.`` are treated as absolute paths. +``.`` as the current and ``..`` as the parent directory. When ``.`` or ``..`` is followed by a character except ``/``, +it is not considered as the current or the parent directory. +All path names are treated as absolute paths unless they start with the current ``.`` or the parent directory ``..``. To import a file ``x`` from the same directory as the current file, use ``import "./x" as x;``. If you use ``import "x" as x;`` instead, a different file could be referenced -- cgit From 41fe412389645fd423c8fb2422db99892f829030 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Mon, 2 Jan 2017 16:47:45 +0100 Subject: interface: change absolutePath() so that ".dir" is considered as an absolute path fixes #1534 --- libsolidity/interface/CompilerStack.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 4095844f..ee55f41a 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -593,11 +593,11 @@ bool CompilerStack::checkLibraryNameClashes() string CompilerStack::absolutePath(string const& _path, string const& _reference) const { - // Anything that does not start with `.` is an absolute path. - if (_path.empty() || _path.front() != '.') - return _path; using path = boost::filesystem::path; path p(_path); + // Anything that does not start with `.` is an absolute path. + if (p.begin() == p.end() || (*p.begin() != "." && *p.begin() != "..")) + return _path; path result(_reference); result.remove_filename(); for (path::iterator it = p.begin(); it != p.end(); ++it) -- cgit From 07f34e0023c395b43c5d63ce5a4d2cf5160025fa Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Tue, 3 Jan 2017 18:16:33 +0100 Subject: test: add a test importing a file name starting with a period --- test/libsolidity/Imports.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp index bc6adc26..e3f0b281 100644 --- a/test/libsolidity/Imports.cpp +++ b/test/libsolidity/Imports.cpp @@ -164,6 +164,14 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings) BOOST_CHECK(c.compile()); } +BOOST_AUTO_TEST_CASE(filename_with_period) +{ + CompilerStack c; + c.addSource("a/a.sol", "import \".b.sol\"; contract A is B {} pragma solidity >=0.0;"); + c.addSource("a/.b.sol", "contract B {} pragma solidity >=0.0;"); + BOOST_CHECK(!c.compile()); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit From 779a01faa9b18a58a133a120d6aebe1df612cb00 Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Fri, 6 Jan 2017 16:21:16 +0100 Subject: Changelog: document #1537 --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index a82e8744..0ac0cb2f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ BugFixes: * Type checker, code generator: enable access to events of base contracts' names. + * Imports: ``import ".dir/a"`` is not a relative path. Relative paths begin with directory ``.`` or ``..``. ### 0.4.7 (2016-12-15) -- cgit