Skip to content

Commit

Permalink
Fixed the bug in PR to pass UTs
Browse files Browse the repository at this point in the history
Signed-off-by: Athish Pranav D <[email protected]>
  • Loading branch information
Athishpranav2003 committed Aug 6, 2024
1 parent c8a3f21 commit 9b19990
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/fluent/config/literal_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ def scan_nonquoted_string(boundary_charset = LINE_END)
end

def scan_embedded_code
src = '#{'+@ss.rest+"\n=begin\n=end\n}"
src = '"#{'+@ss.rest+"\n=begin\n=end\n}"

seek = -1
while (seek = src.index('}', seek + 1))
unless Ripper.sexp(src[0..seek]).nil? # eager parsing until valid expression
unless Ripper.sexp(src[0..seek] + '"').nil? # eager parsing until valid expression
break
end
end
Expand All @@ -168,14 +168,15 @@ def scan_embedded_code
raise Fluent::ConfigParseError, @ss.rest
end

code = src[2, seek-2]
code = src[3, seek-3]

if @ss.rest.length < code.length
@ss.pos += @ss.rest.length
parse_error! "expected end of embedded code but $end"
end

@ss.pos += code.length

'"#{' + code + '}"'
end

Expand Down

0 comments on commit 9b19990

Please sign in to comment.