diff --git a/decouple.py b/decouple.py index 0788928..226fcc9 100644 --- a/decouple.py +++ b/decouple.py @@ -228,6 +228,7 @@ def __call__(self, value): transform = lambda s: self.cast(s.strip(self.strip)) splitter = shlex(value, posix=True) + splitter.escape = '' # Do not escape backslashes splitter.whitespace = self.delimiter splitter.whitespace_split = True diff --git a/tests/test_helper_csv.py b/tests/test_helper_csv.py index 8d55a66..76397ac 100644 --- a/tests/test_helper_csv.py +++ b/tests/test_helper_csv.py @@ -29,3 +29,12 @@ def test_csv_quoted_parse(): assert ['foo', "'bar, baz'", "'qux"] == csv(''' foo ,"'bar, baz'", "'qux"''') assert ['foo', '"bar, baz"', '"qux'] == csv(""" foo ,'"bar, baz"', '"qux'""") + + +def test_csv_backslash(): + csv = Csv() + + raw = r'first,^https://\w+\.example\.com$,third' + + assert ['first', '^https://\\w+\\.example\\.com$', 'third'] == \ + csv(raw), "Csv helper removed backslashes."