You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As reported by several users in #148, version 0.10.0 changed how some .env files are parsed in a breaking way, especially with regards to escapes. I think some of those changes were necessary, but some other may have been unexpected.
Experiment
It was unclear what exactly broke and whether Python-dotenv is consistent with other parsers, so I ran an experiment to compare versions and packages.
The scripts to generate these tables are in bbc2/dotenv-parser-comparisons. I may update them if I find new interesting behavior.
Basic
foo=ab
parser
output
python-dotenv-0.9.1
ab
python-dotenv-0.10.1
ab
bash-5.0.0
ab
js-dotenv-6.2.0
ab
ruby-dotenv-2.6.0
ab
Escaped z
foo=a\zb
parser
output
python-dotenv-0.9.1
a\\zb
python-dotenv-0.10.1
a\zb
bash-5.0.0
azb
js-dotenv-6.2.0
a\zb
ruby-dotenv-2.6.0
a\zb
Escaped and single-quoted z
foo='a\zb'
parser
output
python-dotenv-0.9.1
a\zb
python-dotenv-0.10.1
a\zb
bash-5.0.0
a\zb
js-dotenv-6.2.0
a\zb
ruby-dotenv-2.6.0
a\zb
Escaped and double-quoted z
foo="a\zb"
parser
output
python-dotenv-0.9.1
a\zb
python-dotenv-0.10.1
a\zb
bash-5.0.0
a\zb
js-dotenv-6.2.0
a\zb
ruby-dotenv-2.6.0
azb
Escaped n
foo=a\nb
parser
output
python-dotenv-0.9.1
a\\nb
python-dotenv-0.10.1
a\nb
bash-5.0.0
anb
js-dotenv-6.2.0
a\nb
ruby-dotenv-2.6.0
a\nb
Escaped and single-quoted n
foo='a\nb'
parser
output
python-dotenv-0.9.1
a\nb
python-dotenv-0.10.1
a\nb
bash-5.0.0
a\nb
js-dotenv-6.2.0
a\nb
ruby-dotenv-2.6.0
a\nb
Escaped and double-quoted n
foo="a\nb"
parser
output
python-dotenv-0.9.1
a\nb
python-dotenv-0.10.1
a\nb
bash-5.0.0
a\nb
js-dotenv-6.2.0
a\nb
ruby-dotenv-2.6.0
a\nb
Quoted newline
foo="a
b"
parser
output
python-dotenv-0.9.1
"a
python-dotenv-0.10.1
a\nb
bash-5.0.0
a\nb
js-dotenv-6.2.0
a
ruby-dotenv-2.6.0
a\nb
Non-escaped space
foo=a b
parser
output
python-dotenv-0.9.1
ab
python-dotenv-0.10.1
ab
bash-5.0.0
a
js-dotenv-6.2.0
ab
ruby-dotenv-2.6.0
ab
Non-escaped #
foo=a#b
parser
output
python-dotenv-0.9.1
a#b
python-dotenv-0.10.1
a
bash-5.0.0
a#b
js-dotenv-6.2.0
a#b
ruby-dotenv-2.6.0
a
Non-escaped spaced #
foo=a #b
parser
output
python-dotenv-0.9.1
a#b
python-dotenv-0.10.1
a
bash-5.0.0
a
js-dotenv-6.2.0
a#b
ruby-dotenv-2.6.0
a
Escaped #
foo="a#b"
parser
output
python-dotenv-0.9.1
a#b
python-dotenv-0.10.1
a#b
bash-5.0.0
a#b
js-dotenv-6.2.0
a#b
ruby-dotenv-2.6.0
a#b
UTF-8
foo=é
parser
output
python-dotenv-0.9.1
\xe9
python-dotenv-0.10.1
é
bash-5.0.0
é
js-dotenv-6.2.0
é
ruby-dotenv-2.6.0
é
Quoted UTF-8
foo="é"
parser
output
python-dotenv-0.9.1
é
python-dotenv-0.10.1
é
bash-5.0.0
é
js-dotenv-6.2.0
é
ruby-dotenv-2.6.0
é
Conclusion
Non-quoted escapes (valid or invalid): All up-to-date parsers except Bash do the same thing. Bash removes the \. 0.9.1 added a \, which was obviously incorrect.
Single-quoted invalid escapes: Everything is fine.
Single-quoted valid escapes: 0.10.1 is the only parser that interprets them as control characters.
Double-quoted invalid escapes: It's fine except for Ruby.
Double-quoted valid escapes: All up-to-date parsers except Bash do the same thing. Bash and 0.9.1 keep the original characters instead of interpreting them as control characters.
Pound sign #: Interpreted as a comment delimiter since 0.10.0 if unquoted, even if there is no whitespace preceding it. When quoted or prefixed with whitespace, everything is fine except for JavaScript.
Non-quoted UTF-8: Fixed in 0.10.0. When quoted, everything is fine.
Non-escaped space: Only Bash ignores everything after it (or treats the rest as a command). Other parsers include everything until the end of the line.
My opinion:
(2, 4, 7) are OK.
(1, 5, 8) are where Bash differs from other parsers. It isn't obvious what we should do.
(3, 6) are where python-dotenv 0.10.0 is quite obviously broken and should be fixed.
The text was updated successfully, but these errors were encountered:
As reported by several users in #148, version 0.10.0 changed how some .env files are parsed in a breaking way, especially with regards to escapes. I think some of those changes were necessary, but some other may have been unexpected.
Experiment
It was unclear what exactly broke and whether Python-dotenv is consistent with other parsers, so I ran an experiment to compare versions and packages.
The scripts to generate these tables are in bbc2/dotenv-parser-comparisons. I may update them if I find new interesting behavior.
Basic
a
b
a
b
a
b
a
b
a
b
Escaped
z
a
\
\
z
b
a
\
z
b
a
z
b
a
\
z
b
a
\
z
b
Escaped and single-quoted
z
a
\
z
b
a
\
z
b
a
\
z
b
a
\
z
b
a
\
z
b
Escaped and double-quoted
z
a
\
z
b
a
\
z
b
a
\
z
b
a
\
z
b
a
z
b
Escaped
n
a
\
\
n
b
a
\
n
b
a
n
b
a
\
n
b
a
\
n
b
Escaped and single-quoted
n
a
\
n
b
a
\n
b
a
\
n
b
a
\
n
b
a
\
n
b
Escaped and double-quoted
n
a
\
n
b
a
\n
b
a
\
n
b
a
\n
b
a
\n
b
Quoted newline
"
a
a
\n
b
a
\n
b
a
a
\n
b
Non-escaped space
a
b
a
b
a
a
b
a
b
Non-escaped
#
a
#
b
a
a
#
b
a
#
b
a
Non-escaped spaced
#
a
#
b
a
a
a
#
b
a
Escaped
#
a
#
b
a
#
b
a
#
b
a
#
b
a
#
b
UTF-8
\
x
e
9
é
é
é
é
Quoted UTF-8
é
é
é
é
é
Conclusion
\
. 0.9.1 added a\
, which was obviously incorrect.#
: Interpreted as a comment delimiter since 0.10.0 if unquoted, even if there is no whitespace preceding it. When quoted or prefixed with whitespace, everything is fine except for JavaScript.My opinion:
The text was updated successfully, but these errors were encountered: