Skip to content

Commit

Permalink
Fix parsing bug in the rpm plugin (#1719)
Browse files Browse the repository at this point in the history
Signed-off-by: Davide Cavalca <[email protected]>
  • Loading branch information
davide125 authored Dec 6, 2021
1 parent 8f4752b commit 4108a87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/ohai/plugins/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,27 @@
value = ""
lines[macros_start_idx + 1..macros_end_idx - 1].each do |line|
if line.start_with?("-")
# new macros are always prefixed by a dash
if name
# if we had parsed a macro before, store it
rpm[:macros][name] = value
name = nil
value = ""
else
_prefix, name, value = line.split(" ", 3)
end

# parse the new macro definition
_prefix, name, value = line.split(" ", 3)
else
# continuations have no prefix and just append to the previous one
value += "\n#{line}"
end
end

# Once we're done parsing all lines, we might have a parsed definition
# we haven't stored - if so, store it.
if name
rpm[:macros][name] = value
end
else
logger.trace("Plugin RPM: Could not find rpm. Skipping plugin.")
end
Expand Down
Loading

0 comments on commit 4108a87

Please sign in to comment.