Skip to content

Commit 79e1c0a

Browse files
author
Harry Karvonen
committed
Fix .env -file quote strip.
Remove only first and last quotes.
1 parent 82a58b6 commit 79e1c0a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

decouple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __init__(self, source, encoding=DEFAULT_ENCODING):
136136
k = k.strip()
137137
v = v.strip()
138138
if len(v) >= 2 and ((v[0] == "'" and v[-1] == "'") or (v[0] == '"' and v[-1] == '"')):
139-
v = v.strip('\'"')
139+
v = v[1:-1]
140140
self.data[k] = v
141141

142142
def __contains__(self, key):

tests/test_env.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
KeyWithDoubleQuoteBegin="text
4646
KeyIsSingleQuote='
4747
KeyIsDoubleQuote="
48+
KeyHasTwoSingleQuote="'Y'"
49+
KeyHasTwoDoubleQuote='"Y"'
4850
'''
4951

5052
@pytest.fixture(scope='module')
@@ -128,3 +130,5 @@ def test_env_with_quote(config):
128130
assert '"text' == config('KeyWithDoubleQuoteBegin')
129131
assert '"' == config('KeyIsDoubleQuote')
130132
assert "'" == config('KeyIsSingleQuote')
133+
assert "'Y'" == config('KeyHasTwoSingleQuote')
134+
assert '"Y"' == config('KeyHasTwoDoubleQuote')

0 commit comments

Comments
 (0)