godotenv icon indicating copy to clipboard operation
godotenv copied to clipboard

Multiline string support

Open joho opened this issue 2 years ago • 2 comments

Supersedes #118 (same PR, but rebased off master and with some extra test coverage) and fixes #117

joho avatar Sep 24 '21 10:09 joho

Still failing on Windows. From the CI tests:

--- FAIL: TestLoadQuotedEnv (0.00s)
7
    godotenv_test.go:38: Mismatch for key 'OPTION_K': expected '"line one\nthis is \\'quoted\\'\none more line"' got '"line one\r\nthis is \\'quoted\\'\r\none more line"'
8
    godotenv_test.go:38: Mismatch for key 'OPTION_L': expected '"line 1\nline 2"' got '"line 1\r\nline 2"'
9
    godotenv_test.go:38: Mismatch for key 'OPTION_M': expected '"line one\nthis is \"quoted\"\none more line"' got '"line one\r\nthis is \"quoted\"\r\none more line"'
10
    godotenv_test.go:38: Mismatch for key 'OPTION_J': expected '"line 1\nline 2"' got '"line 1\r\nline 2"'

It looks like we want to convert Windows newlines into Unix newlines.

Perhaps the winning strategy will be to Replace \r\n with \n (then replace \r with \n just to be safe) and then parse without any special conditions for \r thereafter.

Thoughts?

coolaj86 avatar Sep 24 '21 15:09 coolaj86

@joho please see the suggestion I made, that will fix this issue and get this project multiline support

austinsasko avatar Mar 12 '22 21:03 austinsasko

thanks for contributing this work!

would it be possible for me to help with merging?

johnstonmatt avatar Nov 25 '22 19:11 johnstonmatt