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
{{ message }}
Repository navigation
Equals Symbol Causes "Failed to parse dotenv file due to an invalid name". #319
How do you escape the = symbol? It's causing the "Failed to parse dotenv file due to an invalid name" error because of it. It's part of a multiline value.
It is failing at the 2 == symbols at the end of the "private_key" value. If I remove the 2 symbols, it works, but unfortunately, it won't authenticate.
I think the colon in the name is the error here surely?
@GrahamCampbell Sorry this was a typo on my behalf. I've removed that now.
@hexus I have tried with and without the quotes. I have also tried to escape the = symbol with the backslash but to no avail. As soon as I remove both = symbols, it works but of course it fails to authenticate as they're needed.
Right, it looks like the implementation of multiline variables does not support quotes being contained within the string. If we look at the implementation (https://github.com/vlucas/phpdotenv/blob/v3.1.0/src/Lines.php), a multi-line variable's final line is defined to be the first line containing a quote without an equals.
Activity
GrahamCampbell commentedon Jan 7, 2019
I think the colon in the name is the error here surely?
hexus commentedon Jan 7, 2019
Also, the single quotes don't look right.
I do get some weird behaviour with multiline variables at the moment:
Parses as:
If I try escaping the quotes:
I get a fatal error:
hexus commentedon Jan 7, 2019
More interestingly, this parses okay but still includes the surrounding quotes (this seems to happen for single-line values without spaces, too):
Parses as:
bljdavidson commentedon Jan 7, 2019
@GrahamCampbell Sorry this was a typo on my behalf. I've removed that now.
@hexus I have tried with and without the quotes. I have also tried to escape the = symbol with the backslash but to no avail. As soon as I remove both = symbols, it works but of course it fails to authenticate as they're needed.
I really appreciate both your help :)
GrahamCampbell commentedon Jan 7, 2019
Right, it looks like the implementation of multiline variables does not support quotes being contained within the string. If we look at the implementation (https://github.com/vlucas/phpdotenv/blob/v3.1.0/src/Lines.php), a multi-line variable's final line is defined to be the first line containing a quote without an equals.
GrahamCampbell commentedon Jan 7, 2019
@bljdavidson the file provided in the OP is still invalid syntax as far as I can see?
GrahamCampbell commentedon Jan 7, 2019
@hexus Thanks for those test cases. I'll incorporate them into the test suite.
GrahamCampbell commentedon Jan 7, 2019
I won't have time to look into fixing this until Sunday I'm afraid. I've just had a go now, and a good solution isn't immediately obvious to me.
bljdavidson commentedon Jan 7, 2019
@GrahamCampbell Thanks so much for your help. In the mean time, I have tried to make the JSON into a single line and 2 things happen:
So I'm not sure if it's only related to just multiline :/.
P.S. Please forgive me if I've misunderstood anything, as I'm not advanced in PHP :).
Awesome. Nice work 👍
GrahamCampbell commentedon Jan 26, 2019
@bljdavidson @hexus @Korbeil I've prepared a fix at #322. Please let me know what you think.
GrahamCampbell commentedon Jan 26, 2019
@bljdavidson The following should be the format you want:
Notice how I've escaped all double quotes and backslashes.
GrahamCampbell commentedon Jan 26, 2019
@hexus Your example of:
should now parse as:
hexus commentedon Jan 26, 2019
Fabulous 🎉
Thanks very much!