config: accept empty lines in double-quoted strings#5448
Open
AkashKumar7902 wants to merge 1 commit into
Open
Conversation
Handle physical line endings independently from preceding characters so a blank line or an escaped literal backslash before a newline does not look like EOF. Preserve CRLF as a unit for line continuation. Signed-off-by: Akash Kumar <meakash7902@gmail.com>
AkashKumar7902
marked this pull request as ready for review
July 19, 2026 15:56
Watson1978
requested changes
Jul 21, 2026
Watson1978
left a comment
Contributor
There was a problem hiding this comment.
Nice fix.
The token-based handling of line breaks reads much more clearly than the old [^"]-plus-line-end pairing. The small follow-up suggestions on the same change.
Comment on lines
+101
to
+103
| elsif skip(/\\(?:\r\n|[\r\n])/) | ||
| next | ||
| elsif s = scan(/\r\n|[\r\n]/) |
Contributor
There was a problem hiding this comment.
Please remove now unused constant in
fluentd/lib/fluent/config/basic_parser.rb
Line 31 in bc40b6f
And, add constants instead, like
# A physical line break (LF, CR, or CRLF) inside a double-quoted string.
# It is preserved as-is in the resulting value.
LINE_BREAK = /\r\n|[\r\n]/
# A backslash immediately followed by a physical line break.
# It works as a line continuation, so both are stripped from the value.
LINE_CONTINUATION = /\\#{LINE_BREAK}/o
and use them
elsif skip(LINE_CONTINUATION)
next
elsif s = scan(LINE_BREAK)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes:
Fixes #4691
What this PR does / why we need it:
Double-quoted configuration values previously handled a physical line ending together with its preceding character. When the parser was already positioned at a line ending—such as on an empty line or after an escaped literal backslash—it instead reported an unexpected end of file.
Handle backslash line continuations and preserved line endings explicitly. This accepts empty lines, preserves LF and CRLF, and retains the existing single-backslash continuation behavior.
Docs Changes:
None. The existing multiline-string documentation already describes the intended behavior.
Release Note:
config: accept empty lines in double-quoted strings.
Testing:
Automated:
bundle exec rake test TEST=test/config/test_literal_parser.rb— 220 tests, 223 assertions, 0 failures, 0 errorsTEST_ENV_NUMBER=focus4691 bundle exec rake test TEST=test/config/test_config_parser.rb— 56 tests, 106 assertions, 0 failures, 0 errorsbundle exec rake test(two independent runs) — 4,343 tests, 15,829 and 15,830 assertions respectively; 0 failures, 0 errors, 3 pendings, and 36 omissions in bothrubocop— 459 files inspected, no offensesruby -cfor all three changed Ruby files andgit diff --checkManual (Ruby 4.0.6):
f380d996bc828b5cd488b578018c06826ebcbf7eand candidate7d017869a55e179da4d195806f26d33dc485fc9d.fluentd --dry-run; a genuinely unterminated double-quoted value remained rejected.fluentd --no-supervisorprocess throughdummy→record_transformer→stdoutand externally parsed its emitted JSON as{"message":"seed","blank":"world\n\n","literal_backslash":"left\\\nright","continued":"leftright"}.