diff options
author | John Vandenberg <jayvdb@gmail.com> | 2020-10-24 15:10:14 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-24 09:10:14 +0100 |
commit | 74d1f3bd0bafebec7b21f4d4bab3925bd4fdb24d (patch) | |
tree | 4c9ade6e4868556dbca05117708f61552d16f3ce /src | |
parent | 5cc7da8b83cc6f4a8cfbed4edff9d3c01580e75f (diff) | |
download | tox-git-74d1f3bd0bafebec7b21f4d4bab3925bd4fdb24d.tar.gz |
Prevent {} and tighten parsing of {:} (#1715)
Fixes https://github.com/tox-dev/tox/issues/1711
Diffstat (limited to 'src')
-rw-r--r-- | src/tox/config/__init__.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index 26bd429e..aa694670 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -1819,18 +1819,24 @@ class Replacer: start, end = match.span() return match.string[start:end] - # special case: all empty values means ":" which is os.pathsep - if not any(g.values()): + full_match = match.group(0) + # ":" is swallowed by the regex, so the raw matched string is checked + if full_match.startswith("{:"): + if full_match != "{:}": + raise tox.exception.ConfigError( + "Malformed substitution with prefix ':': {}".format(full_match), + ) + return os.pathsep if sub_value == "posargs": return self.reader.getposargs(match.group("default_value")) - try: - sub_type = g["sub_type"] - except KeyError: + sub_type = g["sub_type"] + if not sub_type and not sub_value: raise tox.exception.ConfigError( - "Malformed substitution; no substitution type provided", + "Malformed substitution; no substitution type provided. " + "If you were using `{}` for `os.pathsep`, please use `{:}`.", ) if not sub_type and not g["default_value"] and sub_value == "/": |