From 91fb49d270f0837e851b3e6e6b0f53848f024f6c Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Wed, 13 Jul 2016 15:58:04 +0800 Subject: [PATCH] various: proper escape in regex --- Library/Homebrew/cmd/audit.rb | 2 +- Library/Homebrew/cmd/bottle.rb | 2 +- Library/Homebrew/cmd/create.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 90c08fc4a0..d5ba7df2dc 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -142,7 +142,7 @@ class FormulaAuditor swig ] - FILEUTILS_METHODS = FileUtils.singleton_methods(false).join "|" + FILEUTILS_METHODS = FileUtils.singleton_methods(false).map { |m| Regexp.escape(m) }.join "|" def initialize(formula, options = {}) @formula = formula diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index 5b900a9ba2..d9ba20daf2 100644 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -238,7 +238,7 @@ module Homebrew ignores = [] if f.deps.any? { |dep| dep.name == "go" } - ignores << %r{#{HOMEBREW_CELLAR}/go/[\d\.]+/libexec} + ignores << %r{#{Regexp.escape(HOMEBREW_CELLAR)}/go/[\d\.]+/libexec} end if ARGV.include? "--skip-relocation" diff --git a/Library/Homebrew/cmd/create.rb b/Library/Homebrew/cmd/create.rb index a7aa78e491..eb3bec46fe 100644 --- a/Library/Homebrew/cmd/create.rb +++ b/Library/Homebrew/cmd/create.rb @@ -110,7 +110,7 @@ class FormulaCreator when %r{github\.com/\S+/(\S+)/archive/} @name = $1 else - /(.*?)[-_.]?#{path.version}/.match path.basename + /(.*?)[-_.]?#{Regexp.escape(path.version)}/.match path.basename @name = $1 end end