[rubygems/rubygems] Fix escape of filenames in bundle doctor
https://github.com/rubygems/rubygems/commit/3ede1435ea
This commit is contained in:
parent
a60aba18f0
commit
af59d35570
@ -1,6 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "rbconfig"
|
require "rbconfig"
|
||||||
|
require "shellwords"
|
||||||
|
|
||||||
module Bundler
|
module Bundler
|
||||||
class CLI::Doctor
|
class CLI::Doctor
|
||||||
@ -22,14 +23,14 @@ module Bundler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dylibs_darwin(path)
|
def dylibs_darwin(path)
|
||||||
output = `/usr/bin/otool -L "#{path}"`.chomp
|
output = `/usr/bin/otool -L #{path.shellescape}`.chomp
|
||||||
dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
|
dylibs = output.split("\n")[1..-1].map {|l| l.match(DARWIN_REGEX).captures[0] }.uniq
|
||||||
# ignore @rpath and friends
|
# ignore @rpath and friends
|
||||||
dylibs.reject {|dylib| dylib.start_with? "@" }
|
dylibs.reject {|dylib| dylib.start_with? "@" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def dylibs_ldd(path)
|
def dylibs_ldd(path)
|
||||||
output = `/usr/bin/ldd "#{path}"`.chomp
|
output = `/usr/bin/ldd #{path.shellescape}`.chomp
|
||||||
output.split("\n").map do |l|
|
output.split("\n").map do |l|
|
||||||
match = l.match(LDD_REGEX)
|
match = l.match(LDD_REGEX)
|
||||||
next if match.nil?
|
next if match.nil?
|
||||||
|
@ -133,4 +133,14 @@ RSpec.describe "bundle doctor" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when home contains filesname with special characters" do
|
||||||
|
it "escape filename before command execute" do
|
||||||
|
doctor = Bundler::CLI::Doctor.new({})
|
||||||
|
expect(doctor).to receive(:`).with("/usr/bin/otool -L \\$\\(date\\)\\ \\\"\\'\\\\.bundle").and_return("dummy string")
|
||||||
|
doctor.dylibs_darwin('$(date) "\'\.bundle')
|
||||||
|
expect(doctor).to receive(:`).with("/usr/bin/ldd \\$\\(date\\)\\ \\\"\\'\\\\.bundle").and_return("dummy string")
|
||||||
|
doctor.dylibs_ldd('$(date) "\'\.bundle')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user