Skip to content

Commit

Permalink
Revert escaping logic for metacharacters
Browse files Browse the repository at this point in the history
  • Loading branch information
manuyavuz committed Dec 23, 2019
1 parent 3a73cfc commit 6171a6b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/cocoapods/sandbox/path_list.rb
Expand Up @@ -54,7 +54,8 @@ def read_file_system
dirs = []
files = []
root_length = root.cleanpath.to_s.length + File::SEPARATOR.length
Dir.glob(root + '**/*', File::FNM_DOTMATCH).each do |f|
escaped_root = escape_path_for_glob(root)
Dir.glob(escaped_root + '**/*', File::FNM_DOTMATCH).each do |f|
directory = File.directory?(f)
# Ignore `.` and `..` directories
next if directory && f =~ /\.\.?$/
Expand Down Expand Up @@ -216,6 +217,25 @@ def dir_glob_equivalent_patterns(pattern)
end
end

# Escapes the glob metacharacters from a given path so it can used in
# Dir#glob and similar methods.
#
# @note See CocoaPods/CocoaPods#862.
#
# @param [String, Pathname] path
# The path to escape.
#
# @return [Pathname] The escaped path.
#
def escape_path_for_glob(path)
result = path.to_s
characters_to_escape = ['[', ']', '{', '}', '?', '*']
characters_to_escape.each do |character|
result.gsub!(character, "\\#{character}")
end
Pathname.new(result)
end

#-----------------------------------------------------------------------#
end
end
Expand Down

0 comments on commit 6171a6b

Please sign in to comment.