Improve apt.rb's read_debs

Make it better at handling whitespace in bracketed options

Signed-off-by: Benoît Gastinne <Udyrfrykte@users.noreply.github.com>
This commit is contained in:
Udyrfrykte 2020-08-14 22:39:56 +02:00 committed by Udyrfrykte
parent 80149958e8
commit fe74f4fd5b
2 changed files with 6 additions and 5 deletions

View file

@ -87,13 +87,13 @@ module Inspec::Resources
active = raw_line == line
# formats:
# deb "http://archive.ubuntu.com/ubuntu/" wily main restricted ...
# deb http://archive.ubuntu.com/ubuntu/ wily main restricted ...
# deb [trusted=yes] http://archive.ubuntu.com/ubuntu/ wily main restricted ...
# deb "http://archive.ubuntu.com/ubuntu/" wily main restricted ...
# deb http://archive.ubuntu.com/ubuntu/ wily main restricted ...
# deb [trusted=yes] http://archive.ubuntu.com/ubuntu/ wily main restricted ...
# deb [arch=amd64 trusted=yes] http://archive.ubuntu.com/ubuntu/ wily main restricted ...
# deb cdrom:[Ubuntu 15.10 _Wily Werewolf_ - Release amd64 (20151021)]/ wily main restricted ...
words = line.split
words.delete_at 1 if words[1] && words[1].start_with?("[")
words = line.sub(/^(deb|deb-src)\s+\[.+?\]/, '\1').split
type, url, distro, *components = words
url = url.delete('"') if url

View file

@ -7,4 +7,5 @@ deb http://archive.ubuntu.com/ubuntu/ wily main restricted
deb "http://archive.ubuntu.com/ubuntu/" wily main restricted
deb [arch=amd64] "http://archive.ubuntu.com/ubuntu/" wily main restricted
deb-src http://archive.ubuntu.com/ubuntu/ wily main restricted
deb-src [arch=amd64 trusted=yes] http://archive.ubuntu.com/ubuntu/ wily main restricted
deb cdrom:[Ubuntu 15.10 _Wily Werewolf_ - Release amd64 (20151021)]/ wily main restricted