Skip to content

Commit

Permalink
Escape double-quotes in labels, and suppress labels with value nil
Browse files Browse the repository at this point in the history
  • Loading branch information
candlerb committed Aug 21, 2019
1 parent fdafa10 commit ca6723f
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,8 @@ def labels_to_protocol(data_labels)
data_labels = {} if data_labels.nil?
data_labels = data_labels.merge(@extra_labels)

unless data_labels.nil?
data_labels.each do |k, v|
formatted_labels.push("#{k}=\"#{v}\"")
end
data_labels.each do |k, v|
formatted_labels.push("#{k}=\"#{v.gsub('"','\\"')}\"") if v
end
'{' + formatted_labels.join(',') + '}'
end
Expand Down

0 comments on commit ca6723f

Please sign in to comment.