Skip to content

Commit 4a4fe9a

Browse files
committed
Pull back YAML approach since it fails on multidepth and introduce refining option.
1 parent cde22a1 commit 4a4fe9a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

logstash-core/lib/logstash/util/substitution_variables.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ def replace_placeholders(value)
7676
raise LogStash::ConfigurationError, "Cannot evaluate `#{placeholder}`. Replacement variable `#{name}` is not defined in a Logstash secret store " +
7777
"or as an Environment entry and there is no default value given."
7878
end
79-
# if ENV may carry array string, remove literal brackets and make array
80-
# use YAML for backward compatibility to cover the cases with escaped chars (ex "[\"*\"]" => ["*"])
81-
# YAML.load('*') fails but it is a valid use case
82-
return replacement.is_a?(String) && replacement != '*' ? YAML.load(replacement) : replacement.to_s
79+
# ENV may carry single quote or escaped double quote or single/double quoted entries in array string
80+
if replacement.is_a?(String)
81+
refined = replacement.gsub(/[\\"\\']/, '')
82+
return refined.start_with?('[') && refined.end_with?(']') ? refined[1..-2].split(',').map(&:strip) : refined
83+
end
84+
replacement.to_s
8385
end
8486
end # def replace_placeholders
8587

0 commit comments

Comments
 (0)