Error out in `gclient config` if --name is relative
This helps prevent behavior such as setting '--name .' so that the .gclient
file contains '.' as the name of the solution, and the .gclient file ends
up a sibling of the .git file, rather than a sibling of the git checkout's
containing directory.
R=iannucci@chromium.org, thestig@chromium.org
Review URL: https://codereview.chromium.org/1406053003
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297343 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient.py b/gclient.py
index 8de7e52..fab867b 100755
--- a/gclient.py
+++ b/gclient.py
@@ -1886,6 +1886,12 @@
else:
# specify an alternate relpath for the given URL.
name = options.name
+ if not os.path.abspath(os.path.join(os.getcwd(), name)).startswith(
+ os.getcwd()):
+ parser.error('Do not pass a relative path for --name.')
+ if any(x in ('..', '.', '/', '\\') for x in name.split(os.sep)):
+ parser.error('Do not include relative path components in --name.')
+
deps_file = options.deps_file
safesync_url = ''
if len(args) > 1: