fix: don't treat closing quote as escaped after an escaped backslash
The quoted-value terminator loop in extractVarValue treated any
backslash before a quote as an escape, so values ending in an even
number of backslashes (e.g. FOO="bar\\") parsed as "unterminated
quoted value". Replace the single-byte check with a walk-back that
counts the preceding backslash run — escape only when odd.
Closes#225. Does not address #226 (TrimRightFunc stripping a
legitimate escaped quote at the tail of a value) — that's a
separate bug in a different code path.
Convert the recursive getStatementStart function to an iterative
loop. This prevents potential stack overflow on files with a very
large number of consecutive comment lines.
Ref #232
* Add tests to cover the regression reported in #204
* Add a comment on regex for clarity
* Remove some old code that wasn't doing anything
* Push _all_ parse code into the parser and get tests calling live code
* Add some newline specific tests
* Add some YAML tests for the newline/space split bug
* Fix incorrect terminating of lines on whitespace
* Fix most of the parser regressions
* Bring back FOO.BAR names
* remove some commented out code
* refactor dotenv parser in order to support multi-line variable values declaration
Signed-off-by: x1unix <denis0051@gmail.com>
* Add multi-line var values test case and update comment test
Signed-off-by: x1unix <denis0051@gmail.com>
* Expand fixture tests to include multiline strings
* Update go versions to test against
* Switch to GOINSECURE for power8 CI task
* When tests fail, show source version of string (inc special chars)
* Update parser.go
Co-authored-by: Austin Sasko <austintyler0239@yahoo.com>
* Fix up bad merge
* Add a full fixture for comments for extra piece of mind
* Fix up some lint/staticcheck recommendations
* Test against go 1.19 too
Signed-off-by: x1unix <denis0051@gmail.com>
Co-authored-by: x1unix <denis0051@gmail.com>
Co-authored-by: Austin Sasko <austintyler0239@yahoo.com>