mirror of https://github.com/docker/compose.git
Avoid fallthrough with empty defaults
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
7e787a8c15
commit
71d40c2a9b
|
@ -133,9 +133,8 @@ class TemplateWithDefaults(Template):
|
||||||
braced = mo.group('braced')
|
braced = mo.group('braced')
|
||||||
if braced is not None:
|
if braced is not None:
|
||||||
sep = mo.group('sep')
|
sep = mo.group('sep')
|
||||||
result = self.process_braced_group(braced, sep, mapping)
|
if sep:
|
||||||
if result:
|
return self.process_braced_group(braced, sep, mapping)
|
||||||
return result
|
|
||||||
|
|
||||||
if named is not None:
|
if named is not None:
|
||||||
val = mapping[named]
|
val = mapping[named]
|
||||||
|
|
|
@ -420,3 +420,15 @@ def test_interpolate_unicode_values():
|
||||||
|
|
||||||
interpol("$FOO") == '十六夜 咲夜'
|
interpol("$FOO") == '十六夜 咲夜'
|
||||||
interpol("${BAR}") == '十六夜 咲夜'
|
interpol("${BAR}") == '十六夜 咲夜'
|
||||||
|
|
||||||
|
|
||||||
|
def test_interpolate_no_fallthrough():
|
||||||
|
# Test regression on docker/compose#5829
|
||||||
|
variable_mapping = {
|
||||||
|
'TEST:-': 'hello',
|
||||||
|
'TEST-': 'hello',
|
||||||
|
}
|
||||||
|
interpol = Interpolator(TemplateWithDefaults, variable_mapping).interpolate
|
||||||
|
|
||||||
|
assert interpol('${TEST:-}') == ''
|
||||||
|
assert interpol('${TEST-}') == ''
|
||||||
|
|
Loading…
Reference in New Issue